oracle常見操作語句

2021-06-23 01:27:22 字數 1301 閱讀 1649

這週剛學完oracle,oracle運算元據庫主要有兩種方法:

1>通過客戶端介面操作

2>通過sql語句來運算元據庫

下面是通過查詢資料和課堂筆記總結的一些簡單oracle語句;

1.建立oracle表

create table 表名(

列名1 型別,

列名2 型別

);2.在建好的表中新增列

alter table 表名 add(列名 型別);

3.在oracle表新增主鍵約束和非空約束

alter table 表名 add constraint pk_表名 primary key(列名);

alter table 表名 modify(列名 not null);

4.刪除主鍵約束(兩種方法)

alter table 表名 drop primary key;

alter table 表名 drop constraint pk_表名;

5.刪除oracle表中的列

alter table 表名 drop column 列名;

6.截斷oracle表

truncate table 表名;

7.檢視表結構

desc table 表名;

8.刪除oracle表

drop table 表名;

9.向oracle表插入記錄

insert into 表名 values(內容1,內容2,內容3,內容4);

insert into 表名 values(內容1,內容2);

10.插入某幾列記錄

insert into 表名(列名1,列名2) values(內容1,內容2);

11.建立表(包括主鍵及外來鍵設定)

create table 表名(

列名1 型別

constraint pk_表名 primary key,

列名2 型別 not null,

列名3 型別

constraint fk_表名 reference 表名(列名),

列名3 型別

constraint ck_表名 check(列名3 in(''內容1'',''內容2'',''內容3''))

);12.查詢oracle表中的所有內容

select * from 表名;

13.消除oracle表中重複行

select distict 列名 from 表名;

14.where語句查詢(並且排序,oracle預設是公升序,降序用desc)

select * from 表名 where 條件 order by 列名;

常見sql語句操作

1 基本語法 create table testfmj id int identity 1,1 identity表示自增列的意思,而int identity 1,1 表示從1開始遞增,每次自增1。name varchar 30 default abc varchar 30 age int defau...

Oracle常見命令操作

1.建立表空間 使用者 給使用者授權 create tablespace temptusers datafile d oracle product 10.2.0 oradata oracl temptusers.dbf size 1024m create user e2qoa v3 identifi...

Oracle操作語句之DCL語句

dcl 資料庫控制語言 grant,revoke 主要是對資料庫中使用者的一些許可權控制 首先建立乙個使用者 格式 create user 使用者名稱 identitied by 密碼 例如 create user liujd identified by 123 對這個使用者進行授權操作 grant...