Skip to content

Commit 8295cd8

Browse files
committed
Merge branch 'parameters-syntax-docs' into master
2 parents b524372 + d0ea62f commit 8295cd8

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

sql/parameters.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Parameters
2+
3+
Parameter placeholder markers used in prepared statements.
4+
5+
**Note:** Apache Hive and Spark don't support prepared statements.
6+
7+
## Positional parameters
8+
9+
These come in the form of single question mark (`?`), supported by:
10+
11+
- [BigQuery][]
12+
- [DB2][]
13+
- [MariaDB][]
14+
- [MySQL][]
15+
- [N1QL][]
16+
- [SQLite][]
17+
- [Transact-SQL][]<sup>1</sup>
18+
19+
## Numbered parameters
20+
21+
- [MariaDB][]: `:1`, `:2`, ...<sup>2</sup>
22+
- [N1QL][]: `$1`, `$2`, ...
23+
- [PL/SQL][]: `:1`, `:2`, ...
24+
- [PostgreSQL][]: `$1`, `$2`, ...
25+
- [Redshift][]: `$1`, `$2`, ...
26+
- [SQLite][]: `?1`, `?2`, ...
27+
28+
## Named parameters
29+
30+
- [BigQuery][]: `@` followed by [identifier][] (either quoted or unquoted)
31+
- [DB2][]: colon (`:`) followed by name (the name can include letters, numbers, and the symbols `@`, `#`, `$`, and `_`)
32+
- [N1QL][]: `$` followed by unquoted [identifier][]
33+
- [PL/SQL][]: colon (`:`) followed by name (`[a-zA-Z][a-zA-Z0-9_]*`)
34+
- [SQLite][]: `$`, `@` or `:` followed by unquoted [identifier][]
35+
- [Transact-SQL][]: `@` or `:`<sup>3</sup> followed by name (see also [identifier][] syntax)
36+
37+
### Notes:
38+
39+
1. When using ODBC or OLE DB driver
40+
2. When SQL_MODE=ORACLE enabled.
41+
3. When using Oracle driver.
42+
43+
[identifier]: ./identifiers.md
44+
[bigquery]: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#query_parameters
45+
[db2]: https://www.ibm.com/docs/en/db2/9.7?topic=statements-prepare#r0000975__l975
46+
[mariadb]: https://mariadb.com/kb/en/prepare-statement/
47+
[mysql]: https://dev.mysql.com/doc/refman/8.0/en/prepare.html
48+
[n1ql]: https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/prepare.html#parameters
49+
[pl/sql]: https://docs.oracle.com/en/database/oracle/oracle-database/21/lnoci/using-sql_statements-in-oci.html#GUID-8D6FD01B-5B8A-49A2-BFD8-71B404529F07
50+
[postgresql]: https://www.postgresql.org/docs/14/sql-prepare.html
51+
[redshift]: https://docs.aws.amazon.com/redshift/latest/dg/r_PREPARE.html
52+
[sqlite]: https://sqlite.org/c3ref/bind_blob.html
53+
[transact-sql]: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/configuring-parameters-and-parameter-data-types

sql/syntax.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
Reference of SQL syntax variations.
44

55
- [Identifiers](./identifiers.md)
6+
- [Parameters](./parameters.md)
67
- [SELECT](./select.md)

0 commit comments

Comments
 (0)