Fauna Query Language for SQL users
This section describes a number of common structured query language (SQL) queries and their Fauna Query Language (FQL) equivalents.
While it is almost impossible to provide an exhaustive comparison of every variation of all SQL commands, we provide a very basic comparison of the most used DDL (Data Definition Language) and DML (Data Manipulation Language) queries. As you gain more experience with the Fauna Query language, the ease and power of its syntax should become evident. Complex queries that are difficult, or even impossible, in SQL can be composed very easily in FQL. One very important difference between the two is that FQL is not a declarative language as SQL. Hence the actual path of execution needs to be provided for each query — FQL requires the developer to specify an index in most queries.
DDL | DML | Query |
---|---|---|
Conceptual equivalents
Relational | FaunaDB |
---|---|
Schema |
Database |
Table |
Collection |
Row |
Document |
Index/Materialized Views |
Index |
In these examples below, we use two tables, dept
(departments) and
emp
(Employees) to compare basic operations in both query languages.
These tables have been extensively used in Oracle documentation to
explain various SQL basics.
SQL> DESC emp
Name Null? Type
----------------------------------------- --------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> DESC dept
Name Null? Type
----------------------------------------- --------
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
ZIP NUMBER
Query
Stay tuned for another set of examples in the near future. If you are looking for a specific example, feel free to email me at deba@fauna.com.
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!