MySQL使用笔记

MySQL笔记

数据库的区别

MySQL使用笔记
数据库扩展.PNG

MySQL数据库的使用

MySQL使用笔记
数据库的使用.PNG

进入数据库

MySQL使用笔记
数据库进入.PNG

常用的Dos命令
⦁ 进入文件 :cd C:/Users/DowneyJr/Pictures/Saved Pictures/(拖拽后将斜杠改掉)
⦁ 上级目录 :cd ../
⦁ 根目录 :cd /
数据库

创建数据库
⦁ create database 数据库名[charset:字符编码集]
⦁ create database 数据库名
⦁ create database if not exites 数据库名[charset:字符编码集]
查看数据库
⦁ show databases
查看数据库的创建SQL语句
⦁ show create database 数据库名
更新数据库
⦁ alter database 数据库名 charset-字符编码集
删除数据库
⦁ drop database 数据库名
⦁ drop database if exites 数据库名
使用数据库
⦁ use 数据库名

数据库的操作
创建表
⦁ create table 表名(
⦁ name varchar(10) not null,
⦁ sex char(1) not null,
⦁ id int auto_increment primary key,
id varchar(40) default '地址不详',
⦁ score decimal(3,1)
⦁ )
查看表
⦁ show tables;
查看表的创建SQL语句
⦁ show create table 表名 \G;
查看表结构
⦁ describe 表名;
删除表
⦁ drop table 表名;
如果数据库不支持中文的编码
⦁ 删除不支持的表
⦁ 重新创建设置编码集

数据的操作
插入数据
⦁ insert into 表名 values (a,b,c);
⦁ 自动增长可以写null
⦁ 默认值可以写default
修改数据
⦁ update 表名 set 字段:值 where条件
删除数据
⦁ delete from 表名 where条件
查询数据
⦁ 分页查询:select * from emp limit(3,2);