错误:插入时,时间格式附近出现错误。
例:
--Table "Test"
create table test
(
name varchar(10),
date1 timestamp,
time1 timestamp
);
-- Insertion
insert into test values('xyz','03/03/2014','02:03:04');
“时间戳”类型同时包含时间和日期。您正在尝试分别插入日期和时间。使用日期和时间类型:
--Table "Test"
create table test
(
name varchar(10),
date1 date,
time1 time
);
-- Insertion
insert into test values('xyz','03/03/2014','02:03:04');
或者,仅使用一个字段:
--Table "Test"
create table test
(
name varchar(10),
datetime timestamp
);
-- Insertion
insert into test values('xyz','03/03/2014 02:03:04');
我建议使用第二种方法,因为可用的运算符和函数集要大得多,并且比较时间戳比较容易。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句