使用org.neo4j.jdbc.bolt.BoltDriver连接Neo4j,能否用SQL替代CQL?
Hey there! Great question—let’s break down what you can and can’t do with the org.neo4j.jdbc.bolt.BoltDriver when it comes to SQL vs. Cypher.
Short Answer
Yes, you can use basic SQL-like read queries (like your example SELECT p.* FROM products as p;) with this driver, but there are strict limitations to keep in mind.
What Works
Simple SELECT statements for basic data retrieval are supported. The driver will automatically translate your SQL into equivalent Cypher behind the scenes. For your query:
SELECT p.* FROM products as p;
It would translate to something like this Cypher:
MATCH (p:products) RETURN p.*
This is super useful if you’re more comfortable with SQL syntax for straightforward fetch operations.
Key Limitations
Don’t expect full SQL compatibility—this driver’s SQL support is basic and focused on simple reads:
- Complex SQL features (like multi-table joins, window functions, advanced
GROUP BYaggregations, or subqueries) are not supported. The SQL-to-Cypher translation can’t handle these graph-specific or advanced relational operations. - Write operations (
INSERT,UPDATE,DELETE) using SQL are either severely limited or not supported at all. You’ll need to use native Cypher for most data modification tasks. - Schema operations (
CREATE TABLE,ALTER TABLE) don’t map to Neo4j’s graph schema system (labels, properties, relationships). You’ll have to use Cypher to define or modify your graph structure.
Best Practices
- Stick to SQL only for simple read queries. For anything more complex (like traversing relationships, aggregating graph data, or modifying records), use native Cypher. It’s optimized for Neo4j’s graph database and will let you leverage all its features efficiently.
- If you plan to rely on SQL, double-check the documentation for your specific driver version—support can vary slightly between releases.
内容的提问来源于stack exchange,提问作者Debasish Halder

