1.切换用户:conn+用户名
2.创建表:create table +表名
3.修改表名:alter table +原表名 RENAME TO +新表名
4.在表中增加字段名:alter table +表名 add +字段名 +类型
5.在表中修改字段名:alter table +表名 rename column 原字段名 to 新字段名
6.在表中修改字段类型:alter table +表名 modify +字段名 +数据类型
7.删除字段:alter table +表名 drop clolumn +字段名
8.添加主键:alter table +表名 add primary key
9.创建索引(普通索引):create index +索引名 on +(表名/字段名)
(唯一索引):create unique index +索引名 on +(表名/字段名)
(组合索引):create index +索引名 on +(表名/字段名1,2,3)
(反向索引):create index +索引名 on +(表名/字段名)reverse
(位图索引):create bitmap index +索引名 on(表名/字段名)
10.创建视图:create view +视图名称 as +查询语句;
create view +视图名称 as +查询语句 with read only;
11.删除视图:drop view +视图名称;
12.查询employee表的全部内容:select * from employee;
13.查询employee表中的雇员编号、姓名、职位、基本工资的信息select empno ,ename ,salary,job form employee;
14.查询不是办事员,且工资低与4000的:SELECT *
FROM employee
WHERE job<>'CLERK' AND salary < 4000;
15.查询职位是办事员且工资低于3000的所有员工:SELECT *
FROM employee
WHERE job='CLERK'AND salary < 3000;
16.查询工资低于2000的员工信息:SELECT *
FROM employee
WHERE IN salary < 2000;
17.查询工资在2000~4000之间的所有员工:SELECT *
FROM employee
WHERE salary BETWEEN 2000 AND 4000;
18.查询员工编号为1470、2580、3690的员工信息:SELECT *
FROM employee
WHERE employee_id IN(1470,2580,3690);
19.查询所有员工姓名中A开头的员工:SLECCT *
FROM employee
WHERE ename LIKE 'A%';(如果要查姓名第二个字母为A的员工就将A改为_A,如果要查姓名中带A的就将A改为%A)
按工资由高到底排序:SELECT * FROM employee ORDER BY salary DESC;(如果工资相同,则按雇佣日期先后排序,就在后面加,hiredate ASC;)
数据库基本操作语言
版权声明:本文为qq_50730941原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。