1、启动oracle数据库:
从root切换到oracle用户进入:
su - oracle
进入sqlplus环境,nolog参数表示不登录:
sqlplus /nolog
以管理员模式登录:
sqlplus / as sysdba /nolog
启动数据库
startup;
停止数据库
shutdown immediate
远程连接数据库
sqlplus /nolog conn sys/sys@ip:1521/orainstance as sysdba
也可以直接运行:
dbstart
#启动数据库的脚本
dbshut
#停止数据库的脚本
参考: startup [force][restrict][nomount][migrate][quiet] [pfile=] [mount [exclusive] x | open ] shutdown
2、数据库监听:
启动监听服务: lsnrctl start 停止监听服务: lsnrctl stop 查看监听状态: lsnrctl status
3、用户权限管理:
创建用户: create user rxhz identified by rxhz1007 ; 赋予用户的表空间权限: alter user ittbank default tablespace rxhz; 或者两条命令合并为: 44 create user lican identified by lican default tablespace data_analysis; grant connect,resource,create any table,create any view,SELECT ANY TABLE,COMMENT ANY TABLE,LOCK ANY TABLE, SELECT ANY DICTIONARY,imp_full_database,data_analysis to lican; alter user lican quota unlimited on data_analysis grant connect,dba,resource to rxhz; grant connect,dba,resource to tyga; GRANT debug any procedure, debug connect session to rxhz; grant select on dba_free_space to rxhz; grant select on dba_data_files to rxhz; grant select on dba_tablespaces to rxhz; grant select,insert,update,delete,all on area_lacci to rxhz; 14 create user lican identified by lican default tablespace users; grant connect,resource,create any table,create any view,SELECT ANY TABLE,COMMENT ANY TABLE,LOCK ANY TABLE, SELECT ANY DICTIONARY,imp_full_database,data_analysis to lican; alter user lican quota unlimited on users 删除用户 drop user “name” cascade; 注:cascade参数是级联删除该用户所有对象,经常遇到如用户有对象而未加此参数则用户删不了的问题,所以习惯性的加此参数。 “name”的引号有无都是一样的。 查看当前用户的角色 select * from user_role_privs; select * from session_privs; 查看当前用户的系统权限和表级权限 select * from user_sys_privs; select * from user_tab_privs; 查询用户表 select name from dba_users; 修改用户口令 alter user "name" identified by "password"; 显示当前用户 show user; 解锁用户 alter user rxhz account unlock; 创建角色: create role rxhz_table;
4、数据表及表空间:
创建表空间: create tablespace ittbank datafile '/u01/app/oracle/oradata/ORCL/ittbank.dbf' size 300m autoextend on; 说明:末尾带autoextend on参数表示当表空间大小不够用时会自动扩容,所有建议加上autoextend on参数。 允许已存在的数据文件自动增长 ALTER DATABASE DATAFILE 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF' AUTOEXTEND ON NEXT 5M MAXSIZE 100M; 删除表空间: drop tablespace ittbank including contents and datafiles; 修改表空间大小(注:修改=可以增大,可以减小。) alter database datafile '/u01/app/oracle/oradata/ORCL/ittbank.dbf' resize 200m; 增加表空间大小(注:增加=只能增大,不能减少。) alter tablespace ittbank add datafile '/u01/app/oracle/oradata/ORCL/ittbank.dbf' size 2048m; 查询数据库文件: select * from dba_data_files; 查询当前存在的表空间: select * from v$tablespace; 表空间情况: 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; 查看表结构: desc table; 查看用户当前连接数: select count(*) from v_$session; pl/sql [declare] [ begin] [exception] end set serveroutput on //打开输出开关 begin dbms_output.put_line('hello world!'); //输出结果 end; 修改连接数:(注:要重启数据库) alter system set processes=1000 scope=spfile; shutdown immediate; startup;
郑重声明:
本站有些内容为互联网所得,如有侵权请联系本站删除处理