DDL数据库操作

发布时间 2023-03-29 22:22:09作者: 惊鸿宴远赴人间

DDL数据库操作:
1.查询:
查询所有数据库:show databases;
查询当前数据库:show database();

2.创建:create database [if not exists] 数据库名 [default charset 字符集(utf8mb4)] [collate 排序规则];

3.删除:drop database [if exists] 数据库名;

4.使用:use 数据库名


DDL表操作-查询:
1.查询当前数据库所有表:show tables;
2.查询表结构:desc 表名
3.查询指定表的建表语句:show create table 表名;

DDL表操作-创建:
create table(
字段1 字段1类型[comment 字段1注释],
字段2 字段2类型[comment 字段2注释],
字段3 字段3类型[comment 字段3注释],
......
字段n 字段n类型[comment 字段n注释]
)[comment 表注释];