Questions about adding double quotes to table and field names when querying Oracle SQL statements

Source: Internet
Author: User

Oracle Beginners typically encounter this problem.
Create a table with Navicat visualization, but you can't find it! later found that the ② statement can be queried to

①select * from user;

But if we add double quotes to the user, we can find it!

②select * from "user";

is Oracle different from MySQL, you must add double quotes when querying? That's not so much trouble! So after finding the data to draw the following conclusions:

1. Oracle tables and fields are case-sensitive. Oracle defaults to uppercase, and if we enclose them in double quotes it is case-insensitive, and if not, the system will automatically turn into uppercase.

2. When we use Navicat to create a database using visualizations, Navicat automatically adds "" to us. So the actual code when we create the database is this: (through the files of the SQL statements everywhere, it's not hard to understand why we can't find the table.) )

12345 DROPTABLE "ROOT"."user";CREATE TABLE "ROOT"."user" ("userid" NUMBER(2) NOT NULL)-------到这里,我想那些总是用可视化来创建表和字段的人该吐槽navicat了。
3. Do I create tables and fields with SQL statements?
① do not add double quotes to create a change:
12345678910111213141516 CREATE TABLE "ROOT".personal_user_table (personal_id NUMBER(10) NOT NULL ,login_name VARCHAR2(20 BYTE) NOT NULL ,login_password VARCHAR2(20 BYTE) NOT NULL ,register_time DATE NOT NULL ,fullname VARCHAR2(20 BYTE) NOT NULL ,sex CHAR(1 BYTE) NULL ,id_card CHAR(18 BYTE) NULL ,email VARCHAR2(30 BYTE) NULL ,tel CHAR(11 BYTE) NULL ,address VARCHAR2(64 BYTE) NULL ,work_units VARCHAR2(64 BYTE) NULL ,monthly_income NUMBER(8,2) NULL ,bank_account CHAR(20 BYTE) NULL ,credit_rating NUMBER(1) NULL)

The result is a normal query:

② with double quotes, as we do with the Navicat visualization:

12345678910111213141516 CREATE TABLE "ROOT"."personal_user_table" ("personal_id" NUMBER(10) NOT NULL ,"login_name" VARCHAR2(20 BYTE) NOT NULL ,"login_password" VARCHAR2(20 BYTE) NOT NULL ,"register_time" DATE NOT NULL ,"fullname" VARCHAR2(20 BYTE) NOT NULL ,"sex" CHAR(1 BYTE) NULL ,"id_card" CHAR(18 BYTE) NULL ,"email" VARCHAR2(30 BYTE) NULL ,"tel" CHAR(11 BYTE) NULL ,"address" VARCHAR2(64 BYTE) NULL ,"work_units" VARCHAR2(64 BYTE) NULL ,"monthly_income" NUMBER(8,2) NULL ,"bank_account" CHAR(20 BYTE) NULL ,"credit_rating" NUMBER(1) NULL)


The results are as follows:

It is therefore recommended that:

1. It is recommended that our visual operators develop the habit of writing handwritten SQL statements, and we do not use double quotes when creating them! So that we can get to the same size as MySQL, etc. is not case-sensitive.

3, the more stupid method is the data table name capitalization, this can also avoid this problem

Questions about adding double quotes to table and field names when querying Oracle SQL statements

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.