溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Oracle基礎(chǔ)語句

發(fā)布時(shí)間:2020-06-07 06:20:17 來源:網(wǎng)絡(luò) 閱讀:371 作者:A2017A 欄目:關(guān)系型數(shù)據(jù)庫

1、創(chuàng)建表

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、--創(chuàng)建索引,創(chuàng)建之后,是按照LAST_NAME的值升序存放,it_lastname為索引名

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

        unique:索引值不能重復(fù)。

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

    create index it_lastname on it_employees(last_name);

3、刪除表

         當(dāng)某個(gè)基表不再不需要時(shí),刪除語句

          drop table 表名;

    刪除視圖

         drop view 視圖名;

    刪除索引

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

4、向表中某幾個(gè)字段插入數(shù)據(jù)

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這個(gè)字段

8、order by  分類

select * from it_employees where salary >= 100000 order by salary; -- 按工資進(jìn)行排列 默認(rèn)的升序,由低到高。       降序?yàn)樵诤蠓郊由蟙esc,即:

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


9、group by   對記錄進(jìn)行分組

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





附件:http://down.51cto.com/data/2366584
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI