我这个语句错在哪里了呀
建表语句是这个
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
);
然后就提示我说无效的月份?咋回事呢,咋修改呢
人气:415 ℃ 时间:2020-06-26 14:57:07
解答
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
);
推荐
猜你喜欢
- Simon and Daniel like going skating 怎么变否定句 为什么不用does
- 一个三位数的十位数为a-2,个位数比十位数的三倍多2,百位数比个位数少3,则这个三位数可表示为?
- 1.His borther has lunch at home.改为否定句 2.He likes ice cream very much.改为一般疑问句
- With the development of science,more new technology ______ to the field of information technology
- 改have的否定句
- 长方行,正方行,圆行,三角行,.图形的记算工式,
- 已知正比例函数y1=k1x和反比例函数y1=k2/x的图象都经过(2,1),则k1,k2的值分别是多少
- NH-YJV-4*25是什么意思