oracle中的SQL語句(一)

2022-05-04 01:06:14 字數 1672 閱讀 2562

oracle中有些語句和標準sql有些細微差別。現在總結一些。

oracle中的sql語句總結

1.建立資料表

create table "scott"."director"(

"director_id"   number(6)  not null,

"name"          varchar2(10)     not  null,

"zhicheng"      varchar2(20)     not  null,

"zhiwu"          varchar2(20)     not  null,

constraint  "導師編號主碼"  primary  key("director_id")

using index

tablespace "users"

);create table "scott"."student"(

"student_id"  number(8)      not  null,

"name"       varchar2(10)    not  null,

"professional"  varchar2(10)  not  null,

"birthday"     date     not  null,

"director_id"   number(6)  not null,

constraint  "學生編號主碼" primary  key("student_id")

using index

t ablespace  "users",

ontraint  "導師編號外碼" foreign key("director_id")

);2.

向表中插入資料(注意日期字段)

insert

into "scott"."student"

("student_id","name","professional","birthday","director_id")

values(20020102,'趙敏',' 計算機' , to_date('7-10月-1980', 'dd-mm-yyyy' ), 200202 );

3.截斷資料表

truncate table 使用者名稱.表名[drop|reuse storage]

drop  storage 顯示指明釋放資料表和索引的空間。

reuse  storage 顯示指明不釋放資料表和索引的空間。

4.建立索引

create index " scott"."姓名字段索引"

on "scott"."studenty"("name")

tablespace "index";

5.建立檢視

create or replace view "scott"."studentview"

asselect student_id,name from scott.student with read only;

6.建立使用者

create user"tempuser" profile "default"

identified by "tempuser" default tablespace "users"

account unlock;

grant create  any table to "tempuser" with  admin option

Oracle中的SQL語句

1.選擇部門30中的所有員工.select empno as 部門編號 ename as 員工名稱 job 員工工作 mgr 領導姓名 hiredate sal,comm deptno from emp where deptno 30 select from emp 2.列出所有辦事員 clerk ...

偶遇Oracle中SQL語句中的

之前居然從來沒見到過此類寫法,諸如 select from t spolicy d,v policyemployee g where d.policyno g.policyno 查閱相關資料才發現此法就是外聯的另外一種表現形式其等同於 select from t spolicy d left joi...

Oracle中SQL語句解析的步驟

我們都知道在oracle中每條sql語句在執行之前都需要經過解析,這裡面又分為軟解析和硬解析。那麼這兩種解析有何不同之處呢?它們又分別是如何進行解析呢?oracle內部解析的步驟又是如何進行的呢?下面我們就這些話題進行共同 在oracle中存在兩種型別的sql語句,一類為ddl語句,他們是從來不會共...