mysql常用命令集合

show databases; 查看数据库

use text; 切换数据库
	Database changed 数据库已经切换
create database texts; 创建数据库

drop database texts; 删除数据库

create database text default character set utf8 collate utf8_general_ci; 创建数据库+字符集
	
select * from student; #表的内容

show tables; 查询表

describe student #设计表
或者 desc student;

auto_increment; #自增长

primary key;  主键

alter table student rename student2; 改表名

alter table student add id int ; 增加字段

alter table student  change id ids varchar not null;  更该字段名

alter table student drop id ;(删除字段)

alter table student add constraint pk-name primary key student (name); #添加主键

alter table student add constraint fk-name foreign key (id) references person (id); #添加外键

show engines #查看搜索引擎

show variables like 'storage_engine%';

insert into [表名] values (值);#插入数据

create tabel 新表 ( select * from student );

update 表名 set 列名 = 更新值 where 更新条件;

delete from 表名 where 条件;

truncate table student;  #删除字段

select <列名|表达式|函数|常量>
from <表名>
where <条件>
order by <排序的列名> [ ASC 或 DESC]


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值