Note the case sensitivity of Oracle Objects.

Source: Internet
Author: User

Create a test table in the database. The database version is ORACLE 10.2.0.1.0) and the table name is test in lower case. The script is as follows:

 
 
  1. Create table test
  2. (
  3. Id NUMBER (10 ),
  4. Name VARCHAR2 (20 ),
  5. Sex VARCHAR (2)
  6. )
  7. -- The corresponding data cannot be found.
  8. SELECT * FROM USER_TABLES WHERE TABLE_NAME = 'test'
  9. -- Use uppercase to check the corresponding data
  10. SELECT * FROM USER_TABLES WHERE TABLE_NAME = 'test'
  11. -- The corresponding data cannot be found.
  12. SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = 'test ';
  13. SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'test ';

Next we will use double quotation marks to create another table ("" in ORACLE is used to force case sensitivity and "when using keywords for fields). The script is as follows:

 
 
  1. Create table "test1"
  2. (
  3. "Id" NUMBER (10 ),
  4. "Name" VARCHAR2 (20 ),
  5. "SEX" VARCHAR (2)
  6. )
  7. SELECT * FROM USER_TABLES WHERE TABLE_NAME = 'test1 ';
  8. SELECT * FROM DBA_TABLES WHERE TABLE_NAME = 'test1 ';
  9. SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'test1 ';
  10. SELECT * FROM "test1 ";
  11. -- ORA-00942: Table or attempt not to exist
  12. SELECT * FROM test1;
  13. -- ORA-00904: "NAME": Invalid identifier
  14. SELECT id, Name, sex from "test1 ";
  15. -- ORA-00904: "ID": Invalid identifier
  16. SELECT id, "Name", sex from "test1 ";
  17. SELECT "id", "Name", sex from "test1 ";
  18. -- ORA-00942: Table or attempt not to exist
  19. SELECT "id", "Name", sex from test1;

The above example may seem strange. This phenomenon does not exist in SQL SERVER. This is because when creating a table or field in ORACLE without double quotation marks, ORACLE converts all the table names and field names to uppercase letters and then writes them into the data dictionary. When accessing the data dictionary, ORACLE converts it into a large write without double quotation marks and then searches for the data fields. Double quotation marks are case sensitive. Not only are keywords case insensitive, function names, process names, table names, variable names, user names, and passwords in pl/SQL blocks are case insensitive.

Some people may not like to use uppercase letters for table names and fields, but prefer lowercase or case-insensitive forms. If so, you should pay attention to it when writing scripts in ORACLE, not properly handled, this will bring you "endless troubles"

As shown above, you must add "" to the field; otherwise, an error is reported, where is the fire. Sometimes, people are very careless and forgetful. Therefore, we recommend that you use uppercase letters in ORACLE. This may make you feel a little uncomfortable at first, but just get used to it. It is always better than using "" to bring many hidden risks to subsequent development.

In ORAClE, scripts and fields are often written in uppercase. Some people say they can improve efficiency. This reduces the overhead for forced conversion, if there is no double quotation marks. Some also say these overhead are negligible, there will be no performance issues. Of course, the scripts are all in uppercase and consistent, which can prevent the same script from being parsed multiple times due to Case sensitivity issues. This is certainly true ). The younger brother is not talented and cannot be determined. There is little information on the Internet. I hope you can discuss it.

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.