• ORACLE【0】:基本操作


    最新工作中用到oracle越来越多,自己虽然也能写点SQL、存储过程、触发器什么的,但是对数据库管理还是陌生的很,现在就将自己最近所学的一步一步整理下来。

    1.windows上如何启动oracle

    安装了oracle后,如果长时间不使用,我们倾向把oracle服务全部停掉,当再次需要时重启。如果想运行oracle服务,需要在计算机管理中启动如下服务:

    OracleDBConsoleorcl Oracle控制台服务,orcl是实例标识,使用enterprise manager时需要启动(非必要)

    OracleOraDb10g_home1TNSListener 监听器服务,只有当oracle需要远程访问时才需要启动(非必要)

    OracleServiceORCL 数据库实例,Oracle数据服务的核心(必须启动)

    OracleJobSchedulerORCL Oracle作业调度定时服务(非必要)

    如果是本地开发,并且需要使用PLSQL时,必须启动TNSListener;如果要使用web管理界面,则必须启动OracleDBConsoleorcl

    2.通过脚本启停Oracle

    启动脚本:oraclestart.bat
    @echo off
    net start OracleServiceORCL
    net start OracleOradb10g_home1TNSListener
    pause


    停止脚本:oraclestop.bat
    @echo off
    net stop OracleServiceORCL
    net stop OracleOradb10g_home1TNSListener
    pause

    启动脚本:oraclestart.bat
    @echo off
    net start OracleServiceORCL
    net start OracleOradb10g_home1TNSListener
    pause
    停止脚本:oraclestop.bat
    @echo off
    net stop OracleServiceORCL
    net stop OracleOradb10g_home1TNSListener
    pause

    3.忘记了密码怎么办

    太久没有用,sys和system的密码都忘记了,如何重置呢?

    进入cmd,运行如下命令:

    sqlplus /nolog;

    conn /as sysdba;

    alter user sys identified by sys;

    4. sqlplus conn连接报错怎么办

    使用使用conn /as sysdba时报错,提示ORA-12560: TNS: 协议适配器错误。

    可以通过在系统环境变量中设置新环境变量:oracle_sid=orcl(实例名)或在登陆sqlplus时使用命令:set oracle_sid=orc(实例名)

    5. 如何创建表空间

    a. 使用sysdba登陆plsql

    plus /nolog; conn /as sysdba;

    b. 查看已有的tablespace保存位置:

    select * from v$datafile

    c. 创建表空间

    create tablespace [tablespacename] datafile '[datafilepath]' size [filesize];

    create tablespace jiyq datafile 'D:ORACLEPRODUCT10.2.0ORADATAORCLJIYQ.DBF' size 3000M;

    6. 创建用户并授权

    创建用户

    create user [username] identified by [password] default tablespace [tablespacename];

    create user jiyq identified by jiyq default tablespace jiyq;

    给用户授权

    grant [dba],[connect] to [username];

    grant dba,connect to jiyq;

  • 相关阅读:
    HDU 1069 Monkey and Banana
    HDU 1029 Ignatius and the Princess IV
    HDU 1024 Max Sum Plus Plus
    Gym100923H Por Costel and the Match
    Codeforces 682C Alyona and the Tree
    Codeforces 449B Jzzhu and Cities
    Codeforces (ccpc-wannafly camp day2) L. Por Costel and the Semipalindromes
    Codeforces 598D (ccpc-wannafly camp day1) Igor In the Museum
    Codeforces 1167c(ccpc wannafly camp day1) News Distribution 并查集模板
    快乐数问题
  • 原文地址:https://www.cnblogs.com/jiyuqi/p/3713907.html
Copyright © 2020-2023  润新知