• 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;
  • 相关阅读:
    ImageIO 操作图片
    ThreadLocal
    Mysql表字段命令alter add
    php中的for循环和js中的for循环
    获取当前URL地址和$_GET获取参数
    apache中的vhosts的配置。
    PHP获取前台传过来的时间年份,进行处理。
    php中的htmlspecialchars_decode()函数
    php分页类代码和使用
    cookies插件,记住cookies
  • 原文地址:https://www.cnblogs.com/xuzhaoyang/p/11275077.html
Copyright © 2020-2023  润新知