1. 安装命令
sudo apt-get install mysql-server-5.6
2. 进入后台命令
mysql -uroot -p
3. 数据库命令
create database <数据库名>; (注意分号!!!)
show databases;
drop database <数据库名>;
use <数据库名>;
select database(); (查看当前用的是哪个数据库)
show tables;
4. 表操作
字段类型
1.INT[(M)] 型: 正常大小整数类型
2.DOUBLE[(M,D)] [ZEROFILL] 型: 正常大小(双精密)浮点数字类型
3.DATE 日期类型:支持的范围是1000-01-01到9999-12-31。MySQL以YYYY-MM-DD格式来显示DATE值,但是允许你使用字符串或数字把值赋给DATE列
4.CHAR(M) 型:定长字符串类型,当存储时,总是是用空格填满右边到指定的长度
5.BLOB TEXT类型,最大长度为65535(2^16-1)个字符。
6.VARCHAR型:变长字符串类型
mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));
------------------------------------------------------------------------
desc MyClass;
——————————————————————
drop table MyClass;
——————————————————————
insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);
——————————————————————————————————————
select * from MyClass;
——————————————————————————
elect * from MyClass order by id limit 0,2;
————————————————————————————————
delete from MyClass where id=1;
————————————————————————————
update MyClass set name='Mary' where id=1;
——————————————————————————————