学习二:MySql数据库的基本操作
2016-04-04 18:50
501 查看
学习二:MySql数据库的基本操作
标签(空格分隔): mysql学习二MySql数据库的基本操作
一基于命令行的基本操作
一,基于命令行的基本操作
查看mysql服务是否启动net start "mysql"
- 停止mysql服务
net stop mysql
配置mysql的环境变量
将mysql的bin目录路径添加到系统环境变量PATH中
登陆mysql数据库
mysql -h localhost -u root -p
创建数据库
create database my_school; //创建数据库 show databases; //显示数据库 drop database my_school; //删除数据库
创建数据表
create database school; use school; create table student( name varchar(20) not null comment '姓名', sid int(10) not null primary key, major varchar(50) not null default '电器工程与自动化', tel varchar(11) not null unique key, birthday date not null );
show tables from school; //查看数据库下面的所有表 show columns from student from school; //查看某个表的具体列的信息 describe school.student; //查看某个表的信息 describe school.student name; //查看某个表的某个字段的信息
修改表的结构
use school; alter table student rename new_student; //重命名表的名称 alter table school.new_student change name new_name varchar(20) not null;//修改表的某个字段的名称 alter table school.new_student change new_name new_name varchar(40);//修改表的某个字段的数据类型 alter table school.new_student change major major varchar(50) not null default '计算机科学';//修改表的某个字段的默认值 alter table school.new_student add email varchar(50) not null comment '邮箱';//添加一个新的字段 alter table school.new_student drop email;//删除一个字段
删除表
drop table if exists school.new_student;
备份数据库(mysql5.7)
还原数据库(mysql5.7)
首先执行数据库创建脚本
相关文章推荐
- 《MySQL必知必会学习笔记》组合查询
- MySQL数据库的CRUD操作
- MySQL数据库的连接
- MySQL数据库的连接
- mysql函数编写和存储过程
- mysql索引总结----mysql 索引类型以及创建
- mySQL
- mybatis对mysql进行分页
- MySQL 使用方法简单教程
- MySQL 警告WARN: Establishing SSL connection without server's identity verification is not recommended.解决办法
- mysql安装
- 安装MySQL时停在start server解决办法
- mysql存储过程详解
- mysql自定义函数
- MySQL系列:mysqldump备份具
- mysql小笔记
- MySQL中MySQL Information_Schema表
- mysql常用命令
- MySQL服务基础
- win7 64位下如何安装配置mysql