命令行cmd对mysql数据库的操作

打开mysql:mysql -hlocalhost -uroot -p123456

数据库操作

操作 命令
建库 Create database 库名
卸载库 Drop 库名
显示某库中的所有表 Show databases
选择某库进行操作 Use 库名

表操作

操作 命令
创建表 create table 表名 (属性 char(4) PRIMARY KEY, 属性varchar(50)not null)
显示库中所有表 Show tables
显示某个表 Describe 表名
表改名操作 alter table 原名 rename to 新名
列改名操作(列为空) alter table 表名 rename column A to B 数据类型
添加值(可添加多值) insert into 表名(字段名1,字段名2,…)values(值1,值2,…),(····),(····);
删除表中某行数据(无where时删除整个表) delete from 表名 where 字段名=value; 自增字段不归0
删除表中数据(无where),自增字段归0 truncate table 表名
删除某个表 drop table 表名
更新部分数据(不加where,全部更新) update 表名 set 字段名1=值1,字段名2=值2 where 条件表达式
修改列属性 alter table 表名 modify column 字段名 类型

猜你喜欢

转载自blog.csdn.net/hihui1231/article/details/103595670