linux下使用Oracle常用命令 |
您所在的位置:网站首页 › linux查看数据库监听状态 › linux下使用Oracle常用命令 |
进入Oracle用户 su - oracle以dba身份进入sql语句 sqlplus / as sysdba启动数据库相关命令启动数据库 startup启动监听(关闭监听的命令lsnrctl stop),退出sql编写界面 lsnrctl start关闭数据库服务,在sql编写界面 shutdown immediate常看当前连接用户的信息 select * from user_users;查看数据库的启动状态 (查看进程里面有没 有Oracle数据库这个进程) ps -ef|grep oracle表空间相关命令Sql语句执行的时候要加上分号创建表空间: SQL> create tablespace test_work 2 datafile'/u01/app/oracle/oradata/abc.dbf' 3 size 10M AUTOEXTEND ON;查询当前所有的表空间: select *from DBA_TABLESPACES分类别查看当前的表空间: SQL> select tablespace_name, 2 file_name, 3 round(bytes / (1024 * 1024), 0) total_space(显示出来的数字是以M为单位的) 4 from dba_data_files 5 order by tablespace_name;删除相应的表空间 drop tablespace xxx including contents and datafiles;查看详细数据文件: SQL> select file_name,tablespace_name from dba_data_files;扩展表空间 alter database datafile '/u01/app/oracle/oradata/abc.dbf' resize 20M;查看表空间的名字及文件所在位置 select tablespace_name, file_id, file_name, round(bytes / (1024 * 1024), 0) total_space from sys.dba_data_files order by tablespace_name-查询当前表空间下使用情况 select a.tablespace_name, a.bytes / 1024 / 1024 "sum MB", (a.bytes - b.bytes) / 1024 / 1024 "used MB", b.bytes / 1024 / 1024 "free MB", round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "used%" from (select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name) a, (select tablespace_name, sum(bytes) bytes, max(bytes) largest from dba_free_space group by tablespace_name) b where a.tablespace_name = b.tablespace_name order by ((a.bytes - b.bytes) / a.bytes) desc;
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |