#Oracle基础-常规操作下

哈哈哈!这是一个音乐? 的今天哈哈哈哈

最近重映了哥哥的经典电影~英雄本色

来一波追忆~

0?wx_fmt=png

1)复制表(只复制结构,源表名:a 新表名:b)

法一:select * into b from a where 1<>1

法二:select top 0 * into b from a

2)拷贝表(拷贝数据,源表名:a 目标表名:b) 

insert into b(a, b, c) select d,e,f from b;

3)子查询(表名1:a 表名2:b)

select a,b,c from a where a IN (select d from b ) 或者: select a,b,c from a where a IN (1,2,3)

4)in 的使用方法

select * from table1 where a [not] in (‘值1’,’值2’,’值4’,’值6’)

5)四表联查问题:

select * from a left inner join b on a.a=b.b 

right inner join c on a.a=c.c 

inner join d on a.a=d.d where .....

6)前10条记录

select top 10 * form table1 where 范围

7)包括所有在 TableA 中但不在 TableB和TableC 中的行并消除所有重复行而派生出一个结果表

(select a from tableA ) except (select a from tableB) except (select a from tableC)

8)随机取出10条数据

select top 10 * from tablename order by newid()

9)删除重复记录

Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)

10)列出数据库里所有的表名

select name from sysobjects where type='U'

11)选择从10到15的记录

select top 5 * from (select top 15 * from table order by id asc) table_别名 order by id desc

12)1=1,1=2的使用,在SQL语句组合时用的较多

“where 1=1” 是表示选择全部   “where 1=2”全部不选,

0?wx_fmt=png

0?wx_fmt=png

文章还是蛮全面的~

大家可以点击【阅读全文】去查看呗~

欢迎关注,嘻嘻~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值