一、安裝
跳過
二蒲牧、常用命令行操作
啟動服務(wù):net start mysql
停止服務(wù):net stop mysql
進入命令行管理模式
登錄 mysql -u username -p
登出 quit
顯示數(shù)據(jù)庫信息 show databases;
創(chuàng)建數(shù)據(jù)庫 create database MyDB;
//大小寫不敏感
刪除數(shù)據(jù)庫 drop database MyDB;
選擇使用的數(shù)據(jù)庫 use MyDB
顯示數(shù)據(jù)表 show tables;
命令以
颈渊;
結(jié)尾敛熬,否則命令不會提交稽揭。
三橙数、數(shù)據(jù)表的創(chuàng)建
create table mytable(
id int(5) not null auto_increment Primary key comment '員工號',
name char(10) not null comment '姓名',
age smallint(3) not null default 0 comment '年齡',
birthday date null comment '出生年月',
salary float(15,2) not null default 0.0 comment '工資'
);
查看表創(chuàng)建語句 show create table mytable;
復(fù)制表結(jié)構(gòu) crate table new_table like mytable;
四、索引創(chuàng)建
create unique index myindex on mytable(serial_no);
創(chuàng)建索引有利于提高數(shù)據(jù)查詢的性能虐杯。
五玛歌、數(shù)據(jù)操作
1、表的操作
- 表結(jié)構(gòu)的修改
alter table mytable
add bonus float(15,2) after salary, //after為增加的在XX之后
chang id serial_no int(6) not null; //id修改后serial_no自動為新主鍵
- 表的刪除
drop table mytable;
2擎椰、數(shù)據(jù)的操作(重點)
- 數(shù)據(jù)的查詢
select [ALL | DISTINCT]
- 數(shù)據(jù)的插入
- 數(shù)據(jù)的更新
- 數(shù)據(jù)的刪除