What happens when we define a field name and alias with the same name as the Oracle keyword?
It's really simple, just add "" to this keyword, such as "group"
Look at the following example:
Copy Code code as follows:
sql> DROP TABLE k;
Table dropped
--establishes table K, field name UID (Oracle keyword)
sql> create TABLE K (UID INT);
CREATE TABLE K (UID INT)
ORA-00904:: Invalid IDENTIFIER
--field name plus "Table creation succeeded
sql> create TABLE K (" UID " INT);
Table created
--insert some data
sql> insert INTO K VALUES (1);
1 Row inserted
Sql> INSERT into K VALUES (2);
1 Row inserted
Sql> INSERT into K VALUES (3);
1 Row inserted
--the query does not add "" is normal (does not seem to conform to the specification)
Sql> SELECT UID from K;
UID
----------
5
5
5
sql> Select "UID" from K;
UID
---------------------------------------
1
2
3
--Update must add ""
sql> U Pdate 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 specification
sql> UPDATE k SET "UID" =5 WHERE "UID" = 3;
1 row UPDATED
Summary: Oracle can refer to keywords as aliases for field names and query statements in the form of "keywords". It is best not to use it if it is not a special case, lest it cause errors in the code writing process.