How can we use the oracle keyword as the field name? What should we do when we define the field name and alias with the same name as the oracle keyword? In fact, it is very simple. Just add "", such as "group" www.2cto.com here to see the following example: SQL> DROP TABLE k; Table dropped -- Create TABLE K, field name is UID (oracle keyword) SQL> CREATE TABLE k (UID INT); CREATE TABLE k (UID INT) ORA-00904: invalid IDENTIFIER -- field name plus "" TABLE created successfully
SQL> create table k ("UID" INT); Table created -- INSERT some data SQL> INSERT INTO k VALUES (1); 1 row insertedSQL> INSERT INTO k VALUES (2 ); 1 row insertedSQL> insert into k VALUES (3); 1 row inserted -- it is normal to add "" When querying (it does not seem to comply with the specifications, UID may be a special keyword ???) SQL> SELECT UID FROM k; UID ---------- 5 5 5 5SQL> SELECT "UID" FROM k; UID ------------------------------------- 1 2 3 -- update must be added "" SQL> UPDATE k SET UID = 5 WHERE UID = 3; UPDATE k SET UID = 5 WHERE UID = 3 ORA-01747: invalid user. table. column, table. column, or column specificationSQL> UPDATE k SET "UID" = 5 WHERE "UID" = 3; 1 row UPDATED summary: 1. oracle can reference keywords as field names and alias of query statements in the form of "keywords. If not
Do not use it to avoid errors during code writing. 2. the keyword "" must be capitalized. (Supplement) -- The End --