Oracle常用sql语句

整理一些个人常用到的sql语句:

1.更新一条记录
update 表名称 set 列名称1 = null,列名称2=to_date(‘15:27:10’,’hh24:mi:ss’) where 列名称3 = ‘123’
2.删除一条记录
detele from 表名称 where 列名称 = ‘123’
3.删除一张表
drop table 表名称
4.改变某列字段类型
alter table 表名称 modify 列名称1 varchar2(10)
5.重命名某列名称
alter table 表名称 rename column 列名称1 to 新名字
6.数据表新增一列
alter table 表名称 add 列名称 varchar(100)
7.给列添加注释
comment on column 表名.列名 is ‘姓名’
8.备份一张表
create table 备份名称 as select * from 源表名称
9.查看时间
select sysdate from dual
10.通过数据字典查询字段和字段类型
(1)select column_name,data_type from cols where table_name = ‘表名称’
(2)select column_name,data_type from user_tab_columns where table_name = ‘表名称’
11.查询两个表id相同的字段(联合)
select a.列名1,b.列名2 from 表名称1 a join 表名称2 b on a.id = b.id
12.查看用户表名
select table_name from user_tables
13.查看从100行到200行的记录
select * from (select * from 表名 where rownum < 100 minus select * from 表名 where rownum < 200) order by 字段1
14.查看所有序列
select * from user_sequences
15.查看数据库名
select name from v$instance
16查看实例名
select instance_name from v$instance
17.数据库删除一列
alter table 表名 drop column 列名
18.修改字段数据类型
alter table 表名 modify 字段名 字段类型(字段长度);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值