oracle常用sql語句

常用語句

1.查詢xinxi
  1)select * from aa where ZT=‘0’;
  2)分頁查找(按照在表中行數查找  rowed )
   但是效率不高,個人感覺原理應該是從表頭開始搜索前去前面的就是需要查找的中間段
   select*from(select a.*,rownum m from(select*fromczrk_0)a whererownum<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 不能添加字段長度。

對於數據量比較大,爲了查詢的快速性,最好是建立索引


發佈了43 篇原創文章 · 獲贊 4 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章