mysql学习9:创建数据库

mysql学习9:创建数据库

技术教程gslnedu2025-01-08 17:29:5913A+A-

前言:我也是在学习过程中,不对的地方请谅解


show databases;                                    #查看数据库表
create database name(数据库名);     #创建数据库
drop database name(数据库名);   #删除数据库
use name(数据库名);                         #进入数据库
show tables;                                  #查看数据库中的表
create table  table (id varchar(20),name varchar(50) );           #创建表(表属性)
show  create table table;          #查看创建表时候的属性
alter table class rename admin1;#修改表名
desc  table(表名);                          #查看表结构
alter table <表名>  add <新字段名> <数据类型>   #数据库表中添加新字段
alter table <表名> change <旧字段名> <新字段名> <数据类型>; #修改表内字段名称
alter table <表名> drop <字段名> ; #删除表中某字段
insert into table(表名)   values('0001','wangwei');           #表table插入数据0001,wangwei
select * from table;                   # 查看表中所有数据
select * from table where id='0001';  #查看表中  配置0001的数据
select * from table where id='0001'  and/or  name='wangwei';
selsct *from first_t1 where name like "%wan%" limit 1;    #模糊匹配打印限制为1条

grant all on firstdb.*  to first@'localhost' identified by'123';  #授权给用户first在本地使用密码123登录firstdb所有的表  权限为all(读写等)
drop table table;   #删除表

1、创建2个test的数据库,删除1个创建的数据库

mysql> create database test1;	            //创建测试数据库1,test1
mysql> create database test2;	            //创建测试数据库2,test2
mysql> drop database test1;	            //删除测试数据库1,test1


创建和删除数据库

点击这里复制本文地址 以上内容由朽木教程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

朽木教程网 © All Rights Reserved.  蜀ICP备2024111239号-8