17,377
社区成员
发帖
与我相关
我的任务
分享
create table customers
(
customer_id integer constraint customers_pk primary key,
first_name varchar2(10) not null,
last_name varchar2(10) not null,
dob date,
phone varchar2(12)
);
这个建立的表
insert into customers (customer_id,first_name,last_name,dob,phone)
values(6,'Fred','Brown','01-JAN-1970','800-555-1215');
我插入一条语句的时候提示错误,
--修改成这样
insert into customers
(customer_id, first_name, last_name, dob, phone)
values
(6,
'Fred',
'Brown',
to_date('01-JAN-1970', 'DD-MON-YYYY', 'NLS_DATE_LANGUAGE=AMERICAN'),
'800-555-1215');
--可以直接定义主键,在列后面加上primary key
create table customers(
customer_id integer primary key,
first_name varchar2(10) not null,
last_name varchar2(10) not null,
dob date,
phone varchar2(12)
);
也可与通过命令来修改:
alter table customers add constraint pk_constriant primary key(customer_id);
insert into customers (customer_id,first_name,last_name,dob,phone)
values(6,'Fred','Brown',to_date('1970-01-01','yyyy-mm-dd'),'800-555-1215');