一、原题
http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements008.htm#SQLRF00223
摘录如下:
1) Nonquoted identifiers must begin with an alphabetic character from your database character set. Quoted identifiers can begin with any character.
2) Nonquoted identifiers can contain only alphanumeric characters from your database character set and the underscore (_), dollar sign ($), and pound sign (#).
三、实验
SQL> create table "2e"(id int);
Table created.
SQL> create table 3f(id int);
create table 3f(id int)
*
ERROR at line 1:
ORA-00903: invalid table name
SQL> create table "2*e"(id int);
Table created.
SQL> create table 2*e(id int);
create table 2*e(id int)
*
ERROR at line 1:
ORA-00903: invalid table name
Which is the valid CREATE TABLE statement?
A. CREATE TABLE emp9$# (emp_no NUMBER (4));
B. CREATE TABLE 9emp$# (emp_no NUMBER(4));
C. CREATE TABLE emp*123 (emp_no NUMBER(4));
D. CREATE TABLE emp9$# (emp_no NUMBER(4), date DATE);
答案:A
二、题目解析
A. CREATE TABLE emp9$# (emp_no NUMBER (4));
B. CREATE TABLE 9emp$# (emp_no NUMBER(4));
C. CREATE TABLE emp*123 (emp_no NUMBER(4));
D. CREATE TABLE emp9$# (emp_no NUMBER(4), date DATE);
答案:A
B选项不正确,因为表名不加双引号只能以字母开头。
C选项不正确,因为表名不加双引表名中不能包含*号。
D选项不正确,因为date是keyword, 不能做为列名。
详见联机文档oracle对象命令规则:C选项不正确,因为表名不加双引表名中不能包含*号。
D选项不正确,因为date是keyword, 不能做为列名。
http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements008.htm#SQLRF00223
摘录如下:
1) Nonquoted identifiers must begin with an alphabetic character from your database character set. Quoted identifiers can begin with any character.
2) Nonquoted identifiers can contain only alphanumeric characters from your database character set and the underscore (_), dollar sign ($), and pound sign (#).
三、实验
SQL> create table "2e"(id int);
Table created.
SQL> create table 3f(id int);
create table 3f(id int)
*
ERROR at line 1:
ORA-00903: invalid table name
SQL> create table "2*e"(id int);
Table created.
SQL> create table 2*e(id int);
create table 2*e(id int)
*
ERROR at line 1:
ORA-00903: invalid table name