/*功能:建立 scott 資料庫中的 dept 表
*/create table dept(
deptno int unsigned auto_increment primary key comment '部門編號',
dname varchar(15) comment '部門名稱',
loc varchar(50) comment '部門所在位置'
)engine=innodb default charset=utf8 comment='部門表';
/*功能:建立 scott 資料庫中的 emp 表
*/create table emp(
empno int unsigned auto_increment primary key comment '雇員編號',
ename varchar(15) comment '雇員姓名',
job varchar(10) comment '雇員職位',
mgr int unsigned comment '雇員對應的領導的編號',
hiredate date comment '雇員的僱傭日期',
sal decimal(7,2) comment '雇員的基本工資',
comm decimal(7,2) comment '獎金',
deptno int unsigned comment '所在部門',
foreign key(deptno) references dept(deptno)
)engine=innodb default charset=utf8 comment='雇員表';
/*功能:建立資料庫 scott 中的 salgrade 表,工資等級表
*/create table salgrade(
grade int unsigned comment '工資等級',
losal int unsigned comment '此等級的最低工資',
hisal int unsigned comment '此等級的最高工資'
)engine=innodb default charset=utf8 comment='工資等級表';
/*功能:建立資料庫 scott 的 bonus 表,工資表
*/create table bonus(
ename varchar(10) comment '雇員姓名',
job varchar(9) comment '雇員職位',
sal decimal(7,2) comment '雇員工資',
comm decimal(7,2) comment '雇員資金'
)engine=innodb default charset=utf8 comment='工資表';
/*功能:插入資料庫 scott 中表 dept 的初始化資料
*/insert into dept values (10,'accounting','new york');
insert into dept values (20,'research','dallas');
insert into dept values (30,'sales','chicago');
insert into dept values (40,'operations','boston');
insert into dept values (60,'operfghations','bossgtdfon');
/*功能:插入資料庫 scott 中表 emp 的初始資料
*/insert into emp values (7369,'smith','clerk',7902,'1980-12-17',800,null,20);
insert into emp values (7499,'allen','salesman',7698,'1981-2-20',1600,300,30);
insert into emp values (7521,'ward','salesman',7698,'1981-2-22',1250,500,30);
insert into emp values (7566,'jones','manager',7839,'1981-4-2',2975,null,20);
insert into emp values (7654,'martin','salesman',7698,'1981-9-28',1250,1400,30);
insert into emp values (7698,'blake','manager',7839,'1981-5-1',2850,null,30);
insert into emp values (7782,'clark','manager',7839,'1981-6-9',2450,null,10);
insert into emp values (7788,'scott','analyst',7566,'87-7-13',3000,null,20);
insert into emp values (7839,'king','president',null,'1981-11-17',5000,null,10);
insert into emp values (7844,'turner','salesman',7698,'1981-9-8',1500,0,30);
insert into emp values (7876,'adams','clerk',7788,'87-7-13',1100,null,20);
insert into emp values (7900,'james','clerk',7698,'1981-12-3',950,null,30);
insert into emp values (7902,'ford','analyst',7566,'1981-12-3',3000,null,20);
insert into emp values (7934,'miller','clerk',7782,'1982-1-23',1300,null,10);
/*功能:插入資料庫 scott 中表 salgrade 的初始資料
*/insert into salgrade values (1,700,1200);
insert into salgrade values (2,1201,1400);
insert into salgrade values (3,1401,2000);
insert into salgrade values (4,2001,3000);
insert into salgrade values (5,3001,9999);
sqlserver 微軟
mysql
oracle
db2mongdb
nosql
oracle資料庫統計資訊
exec dbms stats.gather schema stats ownname cbs options gather auto estimate percent dbms stats.auto sample size,method opt for all indexed columns de...
資料庫 Oracle中建立資料庫
create database lihua 網上的說法是 oracle中的例項只對應乙個資料庫,出現此種情況說明oracle資料庫處於mount 裝載 或open狀態,需要使用startup nomount語句進行狀態更改,或者是直接使用dbca的圖形介面來建立 注 經測試,startup nomo...
oracle 資料庫相關資訊檢視
1.查詢所有使用者表空間占用大小 select segment name,tablespace name,sum bytes 1024 1024 m from dba extents where segment type table group by segment name,tablespace ...