大家看完了操作数据库,那么我们就来看看操作数据表
1,创建表:
create table 表名( 字段1 字段类型,字段2 字段类型,...字段n 字段类型);
例:crate table user(_id int ,name text,pw char(10),sex varchar(1));
2,修改表:
1,表名改为aa。
rename table 原表名 to 要修改成表名;
例:rename table user to aa;
2,在已有表的基本上增加一个like列。
alter table 表名 add 字段名 字段类型;
例: alter table user add like text;
3,列名name修改为username。
alter table 表名 change 原字段名 新字段名 字段类型;(注意:字段类型可修改也可不修改,但必须添加)
例:alter table user change name username text;
4,修改like列,使其长度为50,(或者字段数据类型)
alter table 表名 modify 字段名 varchar(50); alter table 表名 modify 字段名 字段类型;
例:alter table user modify like varchar(50);
alter table user modify like text;
3,查询表:
1,查询数据库中所有表
show tables;
2,查看表格的创建细节
show create table 表名;
例:show create table user;
4,删除表:
drop table 表名;
例:drop table user;