mysql学习笔记
时间:2011-01-28 来源:好坏
create table dept
(
deptno int primary key,
dname varchar(14),
loc varchar(13)
);
create table emp
(
empno int primary key,
ename varchar(10),
job varchar(10),
mgr int ,
hiredate datetime,
sal double,
comm double,
deptno int ,
foreign key(deptno) references dept(deptno)
);
常用指令:
show databases; show tables;\.执行文本文件里的SQL语句
limit 取第几到第几条语句,示例:
select * from dept limit 3,2;从第三条记录开始取两条数据
auto_increment自动递增,示例:
create table article
(
id int primary key auto_increment,
title varchar(255)
);
insert into article values(null,'a');
insert into article(title) values('c');
select now();取当前时间
select date_format(now(),'%Y-%m-%d %H:%i:%s');格式化取日期