1、創建表

create table IT_EMPLOYEES
(
ENPLOYEES_ID NUMBER(6) NOT NULL UNIQUE,
FIRST_NAME VARCHAR2(20),
LAST_NAME VARCHAR2(25) NOT NULL,
EMAIL VARCHAR2(25),
PHONE_NUMBER VARCHAR2(20),
JOB_ID VARCHAR2(10),
SALARY NUMBER(8,2),
MANAGER_ID NUMBER(6)
);


2、--創建索引,創建之后,是按照LAST_NAME的值升序存放,it_lastname為索引名

??? create [unique] [ cluster ]? index 索引名 on 表名(字段名);

??????? unique:索引值不能重復。

??????? cluster:建立的索引是聚簇索引。

??? create index it_lastname on it_employees(last_name);

3、刪除表

???????? 當某個基表不再不需要時,刪除語句

????????? drop table 表名;

??? 刪除視圖

???????? drop view 視圖名;

??? 刪除索引

???????? drop index 索引名;
3、向表中插入數據
insert into IT_EMPLOYEES values (1,'liu','bei','qq@qq.com',110,001,100000,1)

4、向表中某幾個字段插入數據

5、insert into IT_EMPLOYEES (ENPLOYEES_ID,LAST_NAME) VALUES (3,'ANAN')

6、alter table it_employees add age int;? --增加age字段,類型為int

7、alter table it_employees drop column? age; --刪除age這個字段

8、order by? 分類

select * from it_employees where salary >= 100000 order by salary; -- 按工資進行排列 默認的升序,由低到高。?????? 降序為在后方加上desc,即:

select * from it_employees where salary >= 100000 order by salary desc;


9、group by?? 對記錄進行分組

select job_id ,avg(salary),sum(salary),max(salary),count(job_id) from it_employees group by job_id;