7、新增字段 alter table 数据表名 add column 字段名 类型 修饰语句 位置; alter table news add column newstime timestamp default current_timestamp after content;
8、修改字段定义 alter table 数据表名 modify column 字段名 新的定义; alter table news modify column content longtext;
9、修改字段名及定义 alter table 数据表名 change column 旧字段名 新字段名 新的定义;
10、删除字段 alter table 数据表名 drop column 字段名;
三、记录操作命令 1、新增记录 insert into 数据表名(字段1,字段2,…,字段n) values(值1,值2,…,值n); 注意:值的数量与类型必须与字段列表数量与类型定义一致
2、查看记录 select 字段列表 from 数据表名 where 条件 order by 字段名 desc limit m,n; select * from news; select * from news where id=10; select * from news order by id desc limit 10; 注意:select语句时SQL中最为强大与复杂的查询语句,有七大子句,每段子句都可以省略, 如果出现,必须出现在正确的位置顺序上,不可以调换先后顺序
3、修改记录 update 数据表名 set 字段1=值1 and 字段2=值2 where 条件; update news set title=‘xxxxx’ where id=1;
4、删除记录 delete from 数据表名 where 条件; delete from news where id=10;