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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章