mysql create的几种用法和将字段设为插入时间

DROP TABLE IF EXISTS basic_info;
CREATE TABLE basic_info
(
id INT(11) NOT NULL auto_increment,
name VARCHAR(20),
c_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '插入时间',
PRIMARY KEY(id)
);

 其他用法:

DROP TABLE IF EXISTS basic_info;
CREATE TABLE basic_info
(
u_id INT(11) NOT NULL auto_increment,
u_name VARCHAR(20),
c_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '插入时间',
PRIMARY KEY(u_id)
)ENGINE=INNODB DEFAULT CHARSET=utf8;

CREATE TABLE user_info LIKE basic_info;

CREATE TABLE person_info 
AS
SELECT u_name, c_time FROM user_info;

 

posted @ 2020-04-25 09:03  正态分个布  阅读(594)  评论(0编辑  收藏  举报