MySQL 建立、删除、显示数据库、数据表

1 建立、删除、显示数据库

-- 建立数据库
create database student_db character set utf8 collate utf8_general_ci;
-- 删除数据库
drop database student_db;
-- 显示全部数据库
show databases;
-- 选择数据库
use student_db;

2 建立、删除、显示数据表

-- 建立表
create table student(
    id int unsigned not null primary key auto_increment,
    name varchar(32) not null
);
-- 删除表
drop table student;
-- 显示全部表
show tables;
-- 显示表结构:字段信息
desc student;
-- 显示表结构:建立表语句
show create table student;
相关文章
相关标签/搜索