oracle常用sql語句

2021-07-22 10:33:21 字數 1301 閱讀 4386

1.查詢xinxi

1)select * from aa where zt=『0』;

2)分頁查詢(按照在表中行數查詢  rowed )

但是效率不高,個人感覺原理應該是從表頭開始搜尋前去前面的就是需要查詢的中間段

select

*from

(select

a.*,

rownum

m from

(select

*from

czrk_0)a

where

rownum

<

400)

where

m >=

100;

或者  select * from t where rownum<=90minus select * from t where rownum<80;

3)查詢一張表的主鍵

select col.column_name fromuser_constraints con,  user_cons_columnscol

where con.constraint_name =col.constraint_name and con.constraint_type='p' and col.table_name = 'img'

查詢一張表中所有欄位的欄位名,資料型別,資料長度

selectcolumn_name,data_type, data_length from all_tab_columns where

2.刪除表

1)刪除指定的表  drop table aa;

2)  刪除表中的資料(清空表) delete from aa;

3) 刪除表中指定的字段  alter table aa drop (id);

4)刪除表中指定欄位的所有資料 update img set picture ='';或者 update img set picture =null;

3. 插入資料

1)向指定的記錄插入資料   alter img set age='20' where id='5';

2) 插入一條新的記錄  insert into img(id,name) values("5","zhangsan");

4.建立表

1)create table tablename(imgs blob, path varchar2(50),name varchar2(23),id varchar2(10),picture blob,date1 date);

注意:blob  date 不能新增字段長度。

對於資料量比較大,為了查詢的快速性,最好是建立索引

oracle常用sql語句

1.解鎖oracle使用者下某個使用者 以內建的scott使用者為例 sql conn as sysdba sql alter user scott account unlock identified by tiger 解釋 首先要切換到sysdba使用者下,否則會提示 許可權不足 error at...

oracle常用SQL語句

最近專案中用到,現記錄一下 新增主鍵 alter table shop spec detail add constraint spec detail id primary key id 新增索引 create index spec detail id on shop spec detail id 給...

Oracle常用SQL語句

今天接到乙個新任務 任務的主要內容簡單點說就是乙個下拉框,乙個查詢條件,乙個 table 顯示。當聽完的時候感覺真的是很簡單,這樣的事情也並非沒有做過。但是當靜下心來仔細分析需求,則會發現其與眾不同之處。1 下拉框中顯示的是我們整個模組的表名稱 2 查詢條件初步設想是根據時間查詢 3 table 第...