mysql新建表和修改字段例子

--新建用户手机表user_telphone,其中user_recordid关联到user_info的recordid字段 //sql脚本的注释符:--

CREATE TABLE `user_telphone` (
  `keyid` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_recordid` int(11) NOT NULL,
  `telphone_num` varchar(20) DEFAULT NULL,
  `create_by` varchar(32) DEFAULT NULL,
  `create_date` datetime DEFAULT NULL,
  `lastupdate_by` varchar(32) DEFAULT NULL,
  `lastupdate_date` datetime DEFAULT NULL,
  `memo` varchar(200) DEFAULT NULL,
  `enable_flag` char(1) DEFAULT 'T',
  PRIMARY KEY (`keyid`),
  KEY `user_recordid` (`user_recordid`),
  CONSTRAINT `user_telphone_fk1` FOREIGN KEY (`user_recordid`) REFERENCES `user_info` (`recordid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


--Web gaga用户表user_info新增两个字段enable_flag和memo //新增表的字段并带备注

alter table `user_info` add enable_flag char(1) DEFAULT 'T' COMMENT '有效性标志';
alter table `user_info` add memo varchar(200) COMMENT '备注';
alter table `user_info` add img_head mediumblob COMMENT '头像';
alter table `user_info` add sign_name varchar(512) COMMENT '签名';


你可能感兴趣的:(mysql,Date,user,table,null,action)