This page covers some fundamental basics for using SQL in Polypheny.
Identifiers
In SQL, an identifier is a name given to a database object. Identifiers in Polypheny must adhere to the following rules:
- Naming: Identifiers should start with a letter and can only contain letters, digits, and underscores.
- Case Sensitivity: Case sensitivity depends on the namespace. The default is not case-sensitive. For instance,
employee
andEmployee
would refer to the same object. - Reserved Keywords: If an identifier name clashes with a reserved keyword, the name needs to be quoted. Quoted identifiers, such as
"user"
, start and end with double quotes.
Operator and Function Names
In Polypheny, operator and function names are always case-insensitive. This means that SELECT
, select
, SeLect
, and so on, are treated as the same.
Strings
Strings in Polypheny are enclosed within single quotes ('
). If you need to use a single quote within a string, it must be escaped by doubling it. For example,
INSERT INTO test VALUES (1, 'A single quote '' needs to be doubled')
will insert the string:
A single quote ' needs to be doubled
Accessing Entities from Different Namespaces
You can access entities (like tables or views) from a different namespace by prefixing the identifier with the namespace name, separated by a dot. For example, if there’s a table employee
in namespace hr
, you could refer to it as hr.employee
.
Queries without a table
In Polypheny, SELECT
queries do not require a FROM
clause. This is contrary to standard SQL where a FROM
clause is typically mandatory. In such cases, Polypheny would return a pseudo table with a single row.
For example, the following is a valid query in Polypheny:
SELECT 42;
This would return a pseudo table with a single row and a single column containing the value 42
.