1、创建数据库
create databasee mydata;
2、选择使用数据库
use mydata;
3、mysql数据类型:
int ,char ,varchar 。。。
参照http://blog.csdn.net/jiemushe1814/article/details/4716069
4、建立emp,dept,salgrade表
create table dept
(
deptno int primary key,
dname varchar(14),
loc varchar(13)
);
create table emp
(
empno int primary key,
ename varcharz(10),
job varchar(10),
mgr int,
hiredate datetime,
sal double,
comm double,
deptno int,
foreign key (deptno) references dept(deptno)
)
用文本管理sql语句
\. c:\\mysql_script\\mydata.sql
create table salgrade
(
grade int primary key,
losal int,
hisal int
);
show tables,show databases;
insert into dept values(10,'sal','bj')
delete from dept where deptno=10;
update dept set deptno=10 where deptno=20;
分页:从第一条往后数3条,不包括第一条。
select * from dept limit 1,3
自增长auto_increment。
create table artic
(
id int primary key auto_increment,
title varchar(255)
)
insert into artic values(null,'a');
insert into artic(title) values('a');
当前时间,date_format
select now();
select data_format(now(),'%Y-%m-%d %H%i%s')