SQL reference
This reference covers the SQL that LibRed’s engine runs, whether it arrives through EF Core, ADO.NET, linq2db or the playground. The engine accepts the same SQL whichever EF Core SQL mode you use, because the mode only changes what EF Core generates.
LibRed’s SQL is Access SQL (Jet SQL) with extensions. Each page marks what is an extension:
- Access SQL: ACE accepts it too.
- LibRed extension: ACE has no syntax for it, so a statement that uses it runs on LibRed only.
Conventions
Section titled “Conventions”| Convention | Meaning |
|---|---|
UPPERCASE |
A keyword. Keywords aren’t case-sensitive. |
italic or lowercase |
A name or value you supply. |
[ … ] |
Optional. |
{ a | b } |
Choose one. |
… |
The preceding item may repeat. |
A name that is a reserved word, or that contains a space, goes in square brackets or backticks:
[Order Details], `Order Details`.
A statement may end with a ;. A command runs one statement.
Wildcards
Section titled “Wildcards”LibRed’s SQL is ANSI-92, the mode ACE’s OLE DB provider uses, so LIKE takes the ANSI wildcards:
| Wildcard | Matches |
|---|---|
% |
Any run of characters, including none. |
_ |
Any single character. |
A calculated column’s expression is the exception. It is evaluated by the Access expression service’s ANSI-89
rules, where the wildcards are * and ?. See CREATE TABLE.
Statements
Section titled “Statements”Data definition (DDL)
Section titled “Data definition (DDL)”| Statement | Purpose |
|---|---|
CREATE TABLE |
Create a table, with its columns and constraints. Also lists the data types. |
ALTER TABLE |
Add, change, drop or rename a column, constraint or index. |
CREATE INDEX |
Create an index on an existing table. |
CREATE VIEW |
Create a stored select query. |
CREATE PROCEDURE |
Create a stored parameterised query. |
DROP |
Delete a table, index, view or procedure. |
Data manipulation (DML)
Section titled “Data manipulation (DML)”| Statement | Purpose |
|---|---|
SELECT |
Query rows. |
SELECT … INTO |
Create a table from a query (a make-table query). |
INSERT |
Add rows (an append query). |
UPDATE |
Change rows. |
DELETE |
Remove rows. |
TRANSFORM … PIVOT |
A crosstab query. |
| Statement | Purpose |
|---|---|
PARAMETERS |
Declare a query’s parameters. |
EXECUTE |
Run a stored procedure. |
IF [NOT] EXISTS … THEN |
Run a statement only if a query returns rows. |
BEGIN, COMMIT, ROLLBACK |
Transactions. |
SELECT @@IDENTITY |
Read a system variable. |