You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/d1/best-practices/query-d1.mdx
+48-18Lines changed: 48 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,10 @@ There are a number of ways you can interact with a D1 database:
12
12
3. Using [D1 REST API](/api/operations/cloudflare-d1-create-database).
13
13
4. Using [D1 Wrangler commands](/d1/wrangler-commands/).
14
14
15
+
:::note
16
+
D1 is compatible with most SQLite's SQL convention since it leverages SQLite's query engine.
17
+
:::
18
+
15
19
## Query D1 with Workers Binding API
16
20
17
21
Workers Binding API primarily interacts with the data plane, and allows you to query your D1 database from your Worker.
@@ -47,29 +51,55 @@ Refer to [Workers Binding API](/d1/worker-api/) for more information.
47
51
48
52
## Query D1 with SQL API
49
53
50
-
D1 is compatible with most SQLite's SQL convention since it leverages SQLite's query engine.
54
+
D1 understands SQLite semantics, which allows you to query a database using SQL statements via Workers BindingAPI or REST API (including Wrangler commands). Refer to [D1 SQL API](/d1/sql-api/sql-statements/) to learn more about supported SQL statements.
51
55
52
-
```sh
53
-
npx wrangler d1 execute prod-d1-tutorial --local --command="SELECT * FROM Customers"
56
+
### Use foreign key relationships
57
+
58
+
When using SQL with D1, you may wish to define and and enforce foreign key constraints across tables in a database. Foreign key constraints allow you to enforce relationships across tables, or prevent you from deleting rows that reference rows in other tables. An example of a foreign key relationship is shown below.
0 commit comments