Mysql操作命令
这里只是作为我记录MySQL操作命令的地方,有时我记不得了然后没带我的笔记就只能百度,百度出来的我自己get不到哈哈哈哈哈哈哈哈哈哈,所以就借用平台来记录啦。也尝试把自己在学习过程中碰到的问题放在这里,供自己回顾参考。
库操作
- 创建数据库 :create database 库名;
- 查看现有的库名:show databases;
- 删除库:drop database 库名;
- 使用库:use 库名;
表操作
-
创建表:create table 表名();
例:create table student(
stu_id int auto_increment not null primary key,
stu_name varchar(10) not null,
major varchar(50) not null); -
查看表结构:desc 表名;
-
添加字段:alter table 表名 add column 新字段名 数据类型、、、 after 已存在的字段名,add column 新字段名 数据类型,、、、;
例:alter table student