标签:oracle
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;
标签:oracle
原文地址:http://pengpengyue.blog.51cto.com/12814524/1916713