sql语句oracle
disablebb
这个作者很懒,什么都没留下…
展开
-
添加数据库表自增列
1.创建数据库表-- Create tablecreate table T_MOBILE_BRAND( ID NUMBER not null, NAME VARCHAR2(200))tablespace MASS_DATA pctfree 10 initrans 1 maxtrans 255 storage ( initi...原创 2011-09-19 13:53:36 · 141 阅读 · 0 评论 -
分页sql
select * from (select a.*, rownum num from (XX) a where rownum = 0;原创 2011-09-26 08:41:37 · 90 阅读 · 0 评论 -
sql查询字段的首字符,重复字符只显示一个
select distinct substr(mm.name,0,1) as fname from t_mobile_model mm where mm.bid = 1 order by fname原创 2011-09-26 10:20:14 · 207 阅读 · 0 评论 -
Oracle 方法记录
=======================================================dbms_output.put_line('status:'||status); ====================================================NVL(EXP1,EXP2),函数返回exp1和exp2 中第一个不为null值。取得前...原创 2011-06-27 14:26:14 · 74 阅读 · 0 评论 -
INSERT INTO SELECT和SELECT INTO FROM
1.INSERT INTO SELECT语句 语句形式为:Insert into Table2(field1,field2,...) select value1,value2,... from Table1 要求目标表Table2必须存在,由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还可以插入常量。2.SELECT INTO...原创 2011-07-05 09:48:16 · 59 阅读 · 0 评论 -
oracle sql 查询子节点
--层次查询示例 select level||'层',lpad(' ',level*5)||id id from test start with superid = '0' connect by prior id=superid; select level||'层',connect_by_isleaf,lpad(' ',level*5)||id id from test start wit...原创 2011-11-01 09:22:58 · 114 阅读 · 0 评论 -
to_date() 时间相减 截取
to_date() 时间相减select to_date(untreat_date,'yyyy-mm-dd hh24:mi:ss')-to_date(reg_date,'yyyy-mm-dd hh24:mi:ss') from XXX where to_date(untreat_date,'yyyy-mm-dd hh24:mi:ss')-to_date(reg_date,'yyyy-m...原创 2011-12-16 10:07:08 · 1412 阅读 · 0 评论 -
取得表某个分组的最大值
select * from tablename a where a.createdate=(select max(b.createdate) from tablename b where a.channel=b.channel)原创 2011-12-23 16:46:49 · 100 阅读 · 0 评论 -
sql 语句
一、基础 1、说明:创建数据库 CREATE DATABASE database-name 2、说明:删除数据库 drop database dbname 3、说明:备份sql server --- 创建 备份数据的 device USE master EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backu...原创 2011-11-23 18:26:27 · 256 阅读 · 0 评论