曾梦闵白银三
2024-6-26 14:43:32 发布在干货资料
【SQL独家资料】 MYSQL技术大全-(7)MySQL操作数据库
【摘选】MYSQL技术大全-冰河编著(MySQL操作数据库)


7.1.1 创建数据库语法
create database database_name;
create database if not exists database_name;


7.2.1 查看MySQL中存在的数据库
show databases;


7.2.2 查看MySQL命令行所在数据库,切换数据库为mysql2
select database();
use mysql2;


7.2.3 查看数据库创建信息
show create database database_name;
show create database database_name \G;


7.3.1 通过重命名数据表修改数据库名称
create database if not exists test_old;
use test_old;
create database if not exists table_test(id int);
show tables;
create database if not exists test_new;
rename table test_old.table_test to test_new.table_test;
drop table if exists test_old;
use test_new;
show tables;


7.3.3 通过创建数据表修改数据库名称
create database if not exists test_new;
create table if not exists test_new.table_test like test_old.table_test;
drop database test_old;
use test_new;
show tables;



7.4.1 创建数据库时指定字符编码
create database [if not exists] database_name default character set character_name collate collate_name [default encryption='N'];
# 查看数据库默认字符编码
show variables like '%character_set_database%';


7.4.2 修改数据库字符编码
alter database database_name character set character_name collate collate_name;


7.5 删除数据库
drop database [if exists] database_name;
1486
10
2
精彩评论10
happypanda铂金二
发表于 2024-7-29 08:40:00 显示全部楼层
收藏了
回复

使用道具 2#

臧硕玄铁一
发表于 2024-8-27 15:11:41 显示全部楼层
回复

使用道具 3#

yh_JLwMmC8B玄铁一
发表于 2024-8-27 19:25:52 显示全部楼层
点赞
回复

使用道具 4#

刘晓茹
发表于 2024-8-28 09:16:58 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 5#

谢亚龙玄铁二
发表于 2024-8-28 09:18:50 显示全部楼层
回复

使用道具 6#

刘晓玉
发表于 2024-8-28 09:19:43 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 7#

张馨悦
发表于 2024-8-28 09:20:03 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 8#

张馨悦
发表于 2024-8-28 09:20:16 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 9#

孙雨薇玄铁二
发表于 2024-8-28 11:02:30 显示全部楼层
点赞收藏
回复

使用道具 10#

12  
高级模式
您需要登录后才可以回帖 登录 | 免费注册

  • 官方微信

    欢迎关注永洪服务号!收费为0,价值无限

    扫码关注
  • 新浪微博

    让每位用户轻松挖掘数据价值!

    访问新浪微博
  • 智能客服
100W

用户等你来哦

Copyright   ©2012-2025  北京永洪商智科技有限公司  (京ICP备12050607) 京公网安备110110802011451号 |《永洪社区协议》
返回顶部