mysql数据库常用操作
数据库常用操作
– 单行注释
/* 多行注释 */
mysql单行注释 在mysql数据库 ` 反引号 代表兼容性
– 建立数据库
create database d1;
#面试题 建立一个数据库,名称为: database 名称为: 学生 管理系统
create database database
;
create database if not exists 学生 管理系统库
;
create database if not exists dbaa default character set utf8;
– 查看服务器支持的所有字符集
show charset;
show variables like ‘char%’;
– 查看建立数据库的语句
show create database d1;
– CREATE DATABASE d1
/*!40100 DEFAULT CHARACTER SET utf8 / /!80016 DEFAULT ENCRYPTION=‘N’ */
CREATE DATABASE IF NOT EXISTS d1
DEFAULT CHARACTER SET utf8;
– 查看所有数据库information_schema performance_schema sys mysql
show databases;
– 删除数据库
drop database d1;
drop database if exists d1; # 判断数据库是否存在,不存在,不报错警告
drop database if exists d1
;
– 使用数据库
select database();
use database
;
drop database if exists d1;
drop database if exists database
;
drop database if exists 学生 管理系统库
;