When the Oracle SQL statement keyword is displayed in the table Field

Source: Internet
Author: User

[Symptom]: syntax errors are always reported when you want to insert data into a table.

For example:Insert into acc. t_rpt_column_info (column_id, table_id, column_name,Order, Position, data_type, metric, dictionary_type_id, cons_rule, cons_desc, txt_id, txt_column_id, is_show, tag_type, can_modify, metric, log_column_id, is_enabled, can_input)

Values ('actiontype', 't_ base_account ','Operation Type', 1, '01','s, 1,1 ','[Operation Type]It cannot be blank and must be compared in the dictionary table.', 'Actiontype ','','Mandatory', 48, 1, '1', '3', '1', '0', 'column18', '1', '1 ');

InOracle SQLIn syntax, field names cannot appear.OracleReserved keywords, such:Select, from, where, and, Or, order, group,. If you want to use the keyword, you can add "";

Test:

SQL> Create Table T1 (Order Number, group varchar2 (10 ));

Create Table T1 (Order Number, group varchar2 (10 ))

*

Error at line 1:

The ORA-00904: Invalid identifier

SQL> Create Table T1 ("order" number, "group" varchar2 (10 ));

 

Table created.

SQL> DESC T1;

Name null? Type

-----------------------------------------------------------------------------

Order Number

Group varchar2 (10)

SQL> insert into T1 (Order, group) values (1, test );

Insert into T1 (Order, group) values (1, 'test ')

*

Error at line 1:

ORA-00928: Missing select keyword

SQL> insert into T1 values (1, 'test ');

 

1 row created.

SQL> insert into T1 ("order", "group") values (2, 'test2 ');

 

1 row created.

SQL> select * from T1;

 

Order Group

--------------------

1 Test

2 Test2

Is such a table causing a lot of trouble?

We recommend that you do not use fields in the table.OracleReserved keywords.

To knowOracleWhich keywords are retained or want to know if the keywords used areOracleIt is very easy to retain:

Select * from V $ reserved_words;

Select * from V $ reserved_words where keyword = upper ('Keyword');

Also, the variable names defined in the stored procedure should not be the same as the field names in the table. In this case, the stored procedure can be compiled. However, the data in the table is incorrect, which is difficult to troubleshoot.

Related Article

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.