我这个语句错在哪里了呀
我这个语句错在哪里了呀
建表语句是这个
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 (
1,'John','Brown','01-JAN-1965','800-555-1211'
);
INSERT INTO customers (
customer_id,first_name,last_name,dob,phone
) VALUES (
2,'Cynthia','Green','05-FEB-1968','800-555-1212'
);
INSERT INTO customers (
customer_id,first_name,last_name,dob,phone
) VALUES (
3,'Steve','White','16-MAR-1971','800-555-1213'
);
INSERT INTO customers (
customer_id,first_name,last_name,dob,phone
) VALUES (
4,'Gail','Black',NULL,'800-555-1214'
);
INSERT INTO customers (
customer_id,first_name,last_name,dob,phone
) VALUES (
5,'Doreen','Blue','20-MAY-1970',NULL
);
然后就提示我说无效的月份?咋回事呢,咋修改呢
Date字段插入时一般用函数,很少直接写.
相对于SQLServer来说,用getdate()函数,可以获取当前日期和时间.你用的是Oracle,可能函数名称有所不同,你自己查查.
例如:
INSERT INTO customers (
customer_id,first_name,last_name,dob,phone
) VALUES (
5,'Doreen','Blue',getdate(),NULL
);
如果你非要直接写,那么,
INSERT INTO customers (
customer_id,first_name,last_name,dob,phone
) VALUES (
5,'Doreen','Blue',1970-5-20,NULL
);