create Table payment_record(
payment_record_id int NOT NULL,
payment_number Varchar(5) NOT NULL UNIQUE,
recieved_from_client Number (8,2) NOT NULL DEFAULT 0.00,
Paid_to_client Number (8,2) NOT NULL DEFAULT 0.00,
payment_date Date NOT NULL,
PRIMARY KEY(payment_record_id));
结果
SQL> create Table payment_record(
2 payment_record_id int NOT NULL,
3 payment_number Varchar(5) NOT NULL UNIQUE,
4 recieved_from_client Number (8,2) NOT NULL DEFAULT 0.00,
5 Paid_to_client Number (8,2) NOT NULL DEFAULT 0.00,
6 payment_date Date NOT NULL,
7 PRIMARY KEY(payment_record_id));
recieved_from_client Number (8,2) NOT NULL DEFAULT 0.00,
*
ERROR at line 4:
ORA-00907: missing right parenthesis
请问我出错了什么?我试图创建一个默认为
的表Paid_to_client
recieved_from_client
如果未分配值,可以生成0.00
答案 0 :(得分:3)
default
子句应该在NOT NULL
规范之前:
SQL> create Table payment_record(
2 payment_record_id int NOT NULL,
3 payment_number Varchar(5) NOT NULL UNIQUE,
4 recieved_from_client Number (8,2) DEFAULT 0.00 NOT NULL,
5 Paid_to_client Number (8,2) DEFAULT 0.00 NOT NULL,
6 payment_date Date NOT NULL,
7 PRIMARY KEY(payment_record_id));
答案 1 :(得分:3)
DEFAULT在NOT NULL之前发生:
create Table payment_record(
payment_record_id int NOT NULL,
payment_number Varchar(5) NOT NULL UNIQUE,
recieved_from_client Number (8,2) DEFAULT 0.00 NOT NULL,
Paid_to_client Number (8,2) DEFAULT 0.00 NOT NULL ,
payment_date Date NOT NULL,
PRIMARY KEY(payment_record_id));
答案 2 :(得分:1)
您必须在列约束之前使用默认值,例如not null。对于reference