Oracle常用sql语句(查询数据库中锁表、查询数据库表字段总数)
2013-01-19 13:12
1076 查看
--查询数据库中被锁住的表
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;
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;
相关文章推荐
- sql语句查询Oracle|sql server|access 数据库里的所有表名,字段名
- SQL常用语句之-查询数据库表中的字段上的重复数据
- sql语句查询Oracle|sql server|access 数据库里的所有表名,字段名
- sql语句查询Oracle|sql server|access 数据库里的所有表名,字段名
- oracle中查询和定位数据库问题的SQL语句
- 不同数据库sql查询表字段以及结构的语句
- 用SQL语句查询数据库中某一字段下相同值的记录方法
- 数据库-Oracle【SQL模糊查询语句(like) 及SQL Server 2005 导入和导出向导】
- oracle数据库常用的99条查询语句
- 关于oracle sql语句查询时 表名和字段名要加双引號的问题具体解释
- Oracle 查询数据库表空间sql语句
- 给数据库字段添加注释,并且可以通过sql语句查询
- Oracle维护常用SQL语句(查询系统表和视图)
- 使用SQL语句查询MySQL,SQLServer,Oracle所有数据库名和表名,字段名
- Oracle 常用数据库sql语句操作
- sql语句查询 sql server access 数据库里的所有表名,字段名
- 查询数据库中所有表及所有字段的SQL语句
- Oracle 常用SQL系统查询语句
- Oracle clob类型的字段作为查询条件的sql语句写法
- 如何用SQL语句,查询数据库(日期+时间字段)中等于某一天的记录