oracle数据库表字段查询语句,Oracle常用sql语句(查询数据库中锁表、查询数据库表字段总数)...

--查询数据库中被锁住的表

Select c.sid,c.serial#,d.name,b.object_name,c.username,c.program,c.osuser

from gv$Locked_object a, All_objects b, gv$session c, audit_actions d

where a.object_id = b.object_id and a.inst_id = c.inst_id(+) and a.session_id = c.sid(+)

and c.command = d.action;

--解除数据库中被锁住的表(SID,SERIAL)

alter system kill session '75,1989';

--查询数据库表字段总数

select count(0) from user_col_comments where table_name = upper('fl_sys_log');

--查询字符串长度(第一个按字符长度计算,第二个是按字节计算)

select length('a大b中国'),lengthb('a大b中国') from dual;

--同表中,存在重复记录时,删除其中一条

delete from tablename a where rowid!=(select min(rowid) from tablename b where a.columnId=b.columnId)

--删除物化视图

drop materialized view log on fl_rent_payplan(创建物化视图的基表名称);--首先删除日志文件

drop materialized view MV_HXMX(物化视图名称);

--命令窗口下,打开输出日志

set serveroutput on;

--将所有的系统权限赋值给某用户

grant all privileges to username;

--创建表空间

create tablespace lg

datafile '/u01/app/oracle/oradata/orcl/lg.dbf' size 1g;

--改变表空间大小

alter database datafile '/u01/app/oracle/oradata/orcl/lg.dbf' resize 3072m;

--查看表空间是否自动增长

SELECT FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE FROM dba_data_files;

--打开表空间自动增长

alter database datafile '/u01/app/oracle/oradata/orcl/lg.dbf' autoextend on;

--每次自动增长200m

alter database datafile '/u01/app/oracle/oradata/orcl/lg.dbf' autoextend on next 200M;

--每次自动增长200m,数据表最大不超过1G

alter database datafile '/u01/app/oracle/oradata/orcl/lg.dbf' autoextend on next 200M maxsize 1024M;

--查看各表空间分配情况

select tablespace_name, sum(bytes) / 1024 / 1024  from dba_data_files group by tablespace_name;

-查看各表空间空闲情况 select tablespace_name, sum(bytes) / 1024 / 1024  from dba_free_space  group by tablespace_name;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值