Keywords should not be used as identifiers
14 a+(b*c), (a+b)*c -- ditto
15
16
17INSERT INTO mnop (m, n) SELECT i, (1e9 + i/2e4)::float FROM generate_series(1, 2e4) AS i(i) RETURNING NOTHING18
19CREATE TABLE midprimarykeyswapcleanup AS SELECT * FROM generate_series(1,3) AS a;
20-- This schema change is used to enable the primary key swap. The backup is not taken during this schema change.
Keywords should not be used as identifiers
186
187ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_orders FOREIGN KEY (l_orderkey) references orders (o_orderkey);
188ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_part FOREIGN KEY (l_partkey) references part (p_partkey);
189ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_supplier FOREIGN KEY (l_suppkey) references supplier (s_suppkey);
Keywords should not be used as identifiers
185) WITH delimiter='|';
186
187ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_orders FOREIGN KEY (l_orderkey) references orders (o_orderkey);
188ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_part FOREIGN KEY (l_partkey) references part (p_partkey);189ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_supplier FOREIGN KEY (l_suppkey) references supplier (s_suppkey);
Keywords should not be used as identifiers
184 'gs://sf-10/lineitem.tbl.8'
185) WITH delimiter='|';
186
187ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_orders FOREIGN KEY (l_orderkey) references orders (o_orderkey);188ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_part FOREIGN KEY (l_partkey) references part (p_partkey);
189ALTER TABLE lineitem ADD CONSTRAINT lineitem_fkey_supplier FOREIGN KEY (l_suppkey) references supplier (s_suppkey);
Keywords should not be used as identifiers
170 INDEX l_cd (l_commitdate ASC),
171 INDEX l_rd (l_receiptdate ASC),
172 INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC),
173 INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC)174);
175
176IMPORT INTO lineitem CSV DATA(
Keywords should not be used as identifiers
169 INDEX l_sd (l_shipdate ASC),
170 INDEX l_cd (l_commitdate ASC),
171 INDEX l_rd (l_receiptdate ASC),
172 INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC),173 INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC)
174);
175
Keywords should not be used as identifiers
168 INDEX l_sk (l_suppkey ASC),
169 INDEX l_sd (l_shipdate ASC),
170 INDEX l_cd (l_commitdate ASC),
171 INDEX l_rd (l_receiptdate ASC),172 INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC),
173 INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC)
174);
Keywords should not be used as identifiers
167 INDEX l_pk (l_partkey ASC),
168 INDEX l_sk (l_suppkey ASC),
169 INDEX l_sd (l_shipdate ASC),
170 INDEX l_cd (l_commitdate ASC),171 INDEX l_rd (l_receiptdate ASC),
172 INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC),
173 INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC)
Keywords should not be used as identifiers
166 INDEX l_ok (l_orderkey ASC),
167 INDEX l_pk (l_partkey ASC),
168 INDEX l_sk (l_suppkey ASC),
169 INDEX l_sd (l_shipdate ASC),170 INDEX l_cd (l_commitdate ASC),
171 INDEX l_rd (l_receiptdate ASC),
172 INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC),
Keywords should not be used as identifiers
165 PRIMARY KEY (l_orderkey, l_linenumber),
166 INDEX l_ok (l_orderkey ASC),
167 INDEX l_pk (l_partkey ASC),
168 INDEX l_sk (l_suppkey ASC),169 INDEX l_sd (l_shipdate ASC),
170 INDEX l_cd (l_commitdate ASC),
171 INDEX l_rd (l_receiptdate ASC),
Keywords should not be used as identifiers
164 l_comment VARCHAR(44) NOT NULL,
165 PRIMARY KEY (l_orderkey, l_linenumber),
166 INDEX l_ok (l_orderkey ASC),
167 INDEX l_pk (l_partkey ASC),168 INDEX l_sk (l_suppkey ASC),
169 INDEX l_sd (l_shipdate ASC),
170 INDEX l_cd (l_commitdate ASC),
Keywords should not be used as identifiers
163 l_shipmode CHAR(10) NOT NULL,
164 l_comment VARCHAR(44) NOT NULL,
165 PRIMARY KEY (l_orderkey, l_linenumber),
166 INDEX l_ok (l_orderkey ASC),167 INDEX l_pk (l_partkey ASC),
168 INDEX l_sk (l_suppkey ASC),
169 INDEX l_sd (l_shipdate ASC),
Keywords should not be used as identifiers
143 'gs://sf-10/orders.tbl.8'
144) WITH delimiter='|';
145
146ALTER TABLE orders ADD CONSTRAINT orders_fkey_customer FOREIGN KEY (o_custkey) references customer (c_custkey);147
148CREATE TABLE lineitem (
149 l_orderkey INTEGER NOT NULL,
Keywords should not be used as identifiers
129 o_shippriority INTEGER NOT NULL,
130 o_comment VARCHAR(79) NOT NULL,
131 INDEX o_ck (o_custkey ASC),
132 INDEX o_od (o_orderdate ASC)133);
134
135IMPORT INTO orders CSV DATA(
Keywords should not be used as identifiers
128 o_clerk CHAR(15) NOT NULL,
129 o_shippriority INTEGER NOT NULL,
130 o_comment VARCHAR(79) NOT NULL,
131 INDEX o_ck (o_custkey ASC),132 INDEX o_od (o_orderdate ASC)
133);
134
Keywords should not be used as identifiers
116 'gs://sf-10/customer.tbl.8'
117) WITH delimiter='|';
118
119ALTER TABLE customer ADD CONSTRAINT customer_fkey_nation FOREIGN KEY (c_nationkey) references nation (n_nationkey);120
121CREATE TABLE orders (
122 o_orderkey INTEGER NOT NULL PRIMARY KEY,
Keywords should not be used as identifiers
102 c_acctbal FLOAT NOT NULL,
103 c_mktsegment CHAR(10) NOT NULL,
104 c_comment VARCHAR(117) NOT NULL,
105 INDEX c_nk (c_nationkey ASC)106);
107
108IMPORT INTO customer CSV DATA(
Keywords should not be used as identifiers
91) WITH delimiter='|';
92
93ALTER TABLE partsupp ADD CONSTRAINT partsupp_fkey_part FOREIGN KEY (ps_partkey) references part (p_partkey);
94ALTER TABLE partsupp ADD CONSTRAINT partsupp_fkey_supplier FOREIGN KEY (ps_suppkey) references supplier (s_suppkey); 95
96CREATE TABLE customer (
97 c_custkey INTEGER NOT NULL PRIMARY KEY,
Keywords should not be used as identifiers
90 'gs://sf-10/partsupp.tbl.8'
91) WITH delimiter='|';
92
93ALTER TABLE partsupp ADD CONSTRAINT partsupp_fkey_part FOREIGN KEY (ps_partkey) references part (p_partkey); 94ALTER TABLE partsupp ADD CONSTRAINT partsupp_fkey_supplier FOREIGN KEY (ps_suppkey) references supplier (s_suppkey);
95
96CREATE TABLE customer (
Keywords should not be used as identifiers
76 ps_supplycost FLOAT NOT NULL,
77 ps_comment VARCHAR(199) NOT NULL,
78 PRIMARY KEY (ps_partkey, ps_suppkey),
79 INDEX ps_sk (ps_suppkey ASC) 80);
81
82IMPORT INTO partsupp CSV DATA(
Keywords should not be used as identifiers
67 'gs://sf-10/supplier.tbl.8'
68) WITH delimiter='|';
69
70ALTER TABLE supplier ADD CONSTRAINT supplier_fkey_nation FOREIGN KEY (s_nationkey) references nation (n_nationkey); 71
72CREATE TABLE partsupp (
73 ps_partkey INTEGER NOT NULL,
Keywords should not be used as identifiers
53 s_phone CHAR(15) NOT NULL,
54 s_acctbal FLOAT NOT NULL,
55 s_comment VARCHAR(101) NOT NULL,
56 INDEX s_nk (s_nationkey ASC) 57);
58
59IMPORT INTO supplier CSV DATA(
Keywords should not be used as identifiers
20 'gs://sf-10/nation.tbl'
21) WITH delimiter='|';
22
23ALTER TABLE nation ADD CONSTRAINT nation_fkey_region FOREIGN KEY (n_regionkey) references region (r_regionkey); 24
25CREATE TABLE part (
26 p_partkey INTEGER NOT NULL PRIMARY KEY,
Keywords should not be used as identifiers
13 n_name CHAR(25) NOT NULL,
14 n_regionkey INTEGER NOT NULL,
15 n_comment VARCHAR(152),
16 INDEX n_rk (n_regionkey ASC) 17);
18
19IMPORT INTO nation CSV DATA(
Keywords should not be used as identifiers
10 WHEN 'hash' THEN 2
11 ELSE 3
12 END
13 END AS TYPE,14 (i.KEYS).n AS ordinal_position,
15 trim(BOTH '"' FROM pg_catalog.pg_get_indexdef(ci.oid, (i.KEYS).n, FALSE)) AS COLUMN_NAME,
16 CASE am.amcanorder
Description
Keywords should not be used as identifiers.
Bad practice
In this example, SUM function is used as an alias.
SELECT
sum.a
FROM foo AS sum
Recommended
Avoid keywords as the name of an alias.
SELECT
vee.a
FROM foo AS vee