How to use oracle keywords as Field Names

Source: Internet
Author: User


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 --

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.