删除表命令:drop table <表名>例如:删除表名为 MyClass 的表mysql> drop table MyClass;插入数据命令:insert into <表名> [( <字段名 1>[,..<字段名 n > ])] values ( 值 1 )[, ( 值 n )]例子:mysql> insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);查询表中的数据查询所有行mysql> select * from MyClass;查询前几行数据例如:查看表 MyClass 中前 2 行数据mysql> select * from MyClass order by id limit 0,2;或者mysql> select * from MyClass limit 0,2;删除表中数据命令:delete from 表名 where 表达式例如:删除表 MyClass 中编号为 1 的记录mysql> delete from MyClass where id=1;修改表中数据命令:update 表名 set 字段=新值,... where 条件mysql> update MyClass set name='Mary' where id=1;在表中增加字段命令:alter table 表名 add 字段 类型 其他;例如:在表 MyClass 中添加了一个字段 passtest,类型为 int(4),默认值为 0mysql> alter table MyClass add passtest int(4) default '0'更改表名命令:rename table 原表名 to 新表名;例如:在表 MyClass 名字更改为 YouClassmysql> rename table MyClass to YouClass;更新字段内容命令:update 表名 set 字段名 = 新内容update 表名 set 字段名 = replace(字段名, '旧内容', '新内容');例如:文章前面加入 4 个空格update article set content=concat(' ', content);
【修改表的语法】
一张表,创建完毕,有了N列.
之后还有可能要增加或删除或修改列
Alter table 表名 add 列名称 列类型 列参数; [加的列在表的最后]
例: alter table m1 add birth date not null default '0000-00-00';
Alter table 表名 add 列名称 列类型 列参数 after 某列 [把新列加在某列后]
例: alter table m1 add gender char(1) not null default '' after username;
Alter table 表名 add 列名称 列类型 列参数 first [把新列加在最前面]
例: alter table m1 add pid int not null default 0 first;
删除列:
Alter table 表名 drop 列名
修改列类型:
Alter table 表名 modify 列名 新类型 新参数
例:alter table m1 modify gender char(4) not null default '';
修改列名及列类型
Alter table 表名 change 旧列名 新列名 新类型 新参数
例:alter table m1 change id uid int unsigned;
转载于:https://www.cnblogs.com/aoyeyuyan/p/5830950.html
相关资源:WPF 使用MVVM设计模式对进行增删改操作