mysql建表时添加时间默认值只存储时分秒且自动存储

mysql建表时添加时间默认值只存储时分秒且自动存储

	CREATE TABLE IF NOT EXISTS THI(
	THIId INT UNSIGNED AUTO_INCREMENT,
	t1 INT UNSIGNED NOT NULL,
	h1 INT UNSIGNED NOT NULL,
	i1 INT UNSIGNED NOT NULL,
	dataTime TIME NOT NULL,/*只存储时分秒*/
	PRIMARY KEY (THIId)
)

1.普通插入

INSERT INTO THI(t1,h1,i1,dataTime) VALUES(23,25,23,CURTIME())

2.防重插入

TIPS:即插入的数据不重复

INSERT INTO THI(t1,h1,i1,dataTime) 
SELECT 11,22,33,CURTIME()
FROM DUAL
WHERE NOT EXISTS
(
	SELECT t1,h1,i1
	FROM THI
	WHERE t1=11 AND h1=22 AND i1=33
);
上一篇:vector.size()切记不要减一个数字!!!


下一篇:02-2-Turtle 代码优化