2020-10-31

连接数据库: mysql -u<username> -p<password>;

显示所有数据库:mysql> show databases;

选择数据库:mysql> use <database name>;

创建一个数据库:mysql> create database <database name> [charset <charset>]; 

删除一个数据库:mysql> drop database <database name>;

修改数据库名:mysql无法直接修改数据库名!

 

显示所有表:mysql> show tables;

删除一张表:mysql> drop table <table name>;

修改表名:mysql> rename table <table name> to <new table name>;

清空表:mysql> truncate <table name>;

快速建一张相似的表:mysql> create table <table name> like <another table>;

查看建表语句:mysql> show create table <table name>;

插入所有字段数据:mysql> insert into <table> values(v1,v2,v3...vn);

修改语句:mysql> update <table> set <filed1=v1> where <expression>;

删除语句:mysql> delete from <table> where <expression>;

删除所有数据:mysql> delete from <table>; 

增加一列:mysql> alter table <table> add <field> <type> [other] '';

在某列后增加一列:mysql> alter table <table> add <field> <type> [other] after <field1>;

添加到第一列:mysql> alter table <table> add <field> <type> [other] first;

删除某一列:mysql> alter table <table> drop <field>;

修改某一列的参数:mysql> alter table <table> modify <field> <type> [other];

修改列名(必须带上参数):mysql> alter table <table> change <old field> <new field> <type> [other];

 

①.增加一列:mysql> alter table <table> add <field> <type> [other] '';

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值