MySQL创建user表:
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) DEFAULT NULL,
`password` varchar(32) DEFAULT NULL,
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`phone` varchar(11) NOT NULL,
`email` varchar(32) NOT NULL,
`type` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
)
user表增加一个性别字段
alter table user add sex varchar(10) not null;
修改性别字段为年龄
alter table user change sex age int(4) not null;
删除年龄字段
alter table user drop COLUMN age
查询数据
select * from user
select name,phone,email from user
select name,phone,email from user where name='张三'
select name,phone,email from user where name like '%张%'//模糊查询,查询名字里带“张”的
增加记录
insert into user(name,phone,email)values('sun','17798746531','[email protected]')
修改数据
update user set name='timy' where id=9
删除数据
delete from user where name = 'timy'