MySQL 8.0.20学习指令

查看当前数据库版本
select version();
创建数据库hehl
create database hehl default charset=utf8;
删除数据库
drop database hehl;
查看数据库
show database;
使用数据库:
use hehl;
查看当前数据库下的表
show tables;
创建数据表:
create table if not exists t_hehl1(		// 如果不存在则创建
->id int unsigned auto_increment,			// 自动加一
->password varchar(20) not null,			// 不为空
->time timestamp,									// 时间戳
->primary key(id))									// 主键
->engine=InnoDB default charset=utf8;	// 存储引擎、编码
显示表结构:
show columns from t_hehl1;
删除数据表:
drop table test1;
向数据表中插入数据:
insert into t_hehl1(id, password, time) values (123, ‘test’, null);
insert into t_hehl1(id, password, time) values (null, 'test', null);	// id属性自增
查看数据表中内容:
select * from t_hehl1;
查找数据表:
select * from t_hehl1 where id=123;
修改数据表:
update t_hehl1 set password='change' where id=123;
删除某一个数据表:
delete from t_hehl1 where id = 124;
按条件查找数据表:
select * from t_hehl1 where password like '%change';
将多个数据表中集合某项数据(如下图)
select password from t_hehl1
->union
->select password from t_hehl2
->order by password;

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值