mysql \. 执行脚本文件 mysql> \. C:\\mydata.sql
向上键 能输入以前输入过的文字
--为注释
show create table article; 看 article表的结构
article | CREATE TABLE `article` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pid` int(11) DEFAULT NULL,
`rootid` int(11) DEFAULT NULL
`title` varchar(255) DEFAULT NULL,
`cont` text,
`pdate` datetime DEFAULT NULL,
`isleaf` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=gb2312 |
show databases; 看有多少数据库
show tables; 看有多少表
desc dept(表名); 看表的结构
insert into dept values(10,'A','A');
commit
数据库区别: 数据类型(数值,文本,日期,二进制对象)
分页程序(一页显示三条),
自动递增字段
分页 select * from dept order by deptno desc limit 3, 3;(从第三条
向后数两条)
> create table article
> (
> id int primary key auto_increment,
> tiele varchar (255)
> ); 自动递增
select now(); 取当前时间
select date_format(now(),'%Y-%m-%d %h-%i-%s');
select date_format(now(),'%Y-%m-%d %s-%i-%h');
select date_format(now(),'%Y-%m-%d %h-%i-%h');
insert into emp values (9999,'test','clerk',7369,'1981-12-1
12:10:10', 8000,20,10);
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)
);
create table dept
(
deptno int primary key,
dname varchar(14),
loc varchar(13)
);