oracle xe tips

本文介绍了 Oracle XE 数据库的基本操作,包括使用 SQL*Plus 登录、启动和关闭数据库、远程连接设置、数据文件类型及位置、创建数据库、解决临时文件丢失问题等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. using sqlplus with no login name
   sqlplus /nolog
  
   Should set $ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

2. startup db

   sqlplus /nolog
   connect / as sysdba
   startup
   exit

3. shutdown db
  
   sqlplus /nolog
   connect / as sysdba
   shutdown immediate
   exit

4. enabling remote http connection

   EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);

5. change password:

   ALTER USER SYS IDENTIFIED BY newpassword;
   ALTER USER SYSTEM IDENTIFIED BY newpassword;

6. connect remote oracle server with sqlplus

   connect sys/123@10.1.1.8/XE as sysdba

7. data file type:
root@fs:/usr/lib/oracle/xe/oradata/XE# ls -ltr
total 1078224
-rw-r----- 1 oracle dba 104865792 2007-08-12 16:07 users.dbf
-rw-r----- 1 oracle dba  20979712 2007-08-12 16:45 temp.dbf
-rw-r----- 1 oracle dba 450895872 2007-08-12 22:30 sysaux.dbf
-rw-r----- 1 oracle dba 356524032 2007-08-12 22:38 system.dbf
-rw-r----- 1 oracle dba 183508992 2007-08-12 22:39 undo.dbf
-rw-r----- 1 oracle dba   7061504 2007-08-12 22:46 control.dbf
 
SYSTEM

This tablespace is automatically created when Oracle Database XE is installed. It contains the data dictionary, which is the central set of tables and views used as a read-only reference for the database. It also contains various tables and views that contain administrative information about the database. These are all contained in the SYS schema, and can be accessed only by user SYS or other administrative users with the required privilege.

SYSAUX

This is an auxiliary tablespace to the SYSTEM tablespace, and is also automatically created upon installation. Some database components and products use this tablespace. The HR sample schema is also stored in the SYSAUX tablespace.

TEMP

This tablespace stores temporary data generated when processing SQL statements. For example, this tablespace is used for sort work space. The TEMP tablespace is specified as the default temporary tablespace for every user.

UNDO

This is the tablespace used by the database to store undo information.

USERS

This tablespace is used to store permanent user objects and data. In Oracle Database XE, USERS is the assigned default tablespace for all users except the SYS user, which has the default permanent tablespace of SYSTEM.

8. create your own db;

http://fat-penguin.mocasting.com/p/111421#ManualConfig

  SQL> startup nomount

# 建立數據庫

  SQL> create database “newxe”
      1  maxinstances 1
      2  maxloghistory 1
      3  maxlogfiles 3
      4  maxlogmembers 3
      5  maxdatafiles 50
      6  datafile
      7  '/usr/lib/oracle/xe/oradata/NEWXE/system01.dbf'
      8  size 300m
      9  autoextend on
     10  extend management local  9  sysaux datafile
     11  '/usr/lib/oracle/xe/oradata/NEWXE/sysaux01.dbf'
     12  size 120m
     13  autoextend on
     14  smallfile default temporary tablespace temp
     15  tempfile
     16  '/usr/lib/oracle/xe/oradata/NEWXE/temp01.dbf'
     17  size 20m
     18  autoextend on
     19  smallfile undo tablespace undo
     20  datafile
     21  '/usr/lib/oracle/xe/oradata/NEWXE/undo01.dbf'
     22  size 200m
     23  autoextend on
     24  character set al32utf8
     25  national character set al16utf16
     26  logfile group 1 size 50m,
     27  group 2 size 50m
     28  user sys identified by [sys_password]
     29  user system identified by [system_password];

# 建立 Data Dictionary,執行以下 SQL 檔

    @?/rdbms/admin/catalog.sql
    @?/rdbms/admin/catproc.sql

9. temp file missing:

SQL> connect / as sysdba;
已连接。
SQL> select name from v$tempfile;

未选定行

SQL> alter tablespace temp add tempfile '/usr/lib/oracle/xe/oradata/XE/temp.dbf' size 10M
  2  /

表空间已更改。

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/usr/lib/oracle/xe/oradata/XE/temp.dbf
9. temp file missing:

SQL> connect / as sysdba;
已连接。
SQL> select name from v$tempfile;

未选定行

SQL> alter tablespace temp add tempfile '/usr/lib/oracle/xe/oradata/XE/temp.dbf' size 10M
  2  /

表空间已更改。

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/usr/lib/oracle/xe/oradata/XE/temp.dbf

10. ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
 
SQL> connect / as sysdba;
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
 
Total System Global Area  235999352 bytes
Fixed Size                   450680 bytes
Variable Size             201326592 bytes
Database Buffers           33554432 bytes
Redo Buffers                 667648 bytes
shutdown immeDatabase mounted.
           
SQL> 
SQL> Recover database using backup controlfile until cancel;
ORA-00279: change 31499022 generated at 03/07/2004 12:13:55 needed for thread 1
ORA-00289: suggestion : /var/oracle9i/oradata/coredata/arch/log_1_140.arc
ORA-00280: change 31499022 for thread 1 is in sequence #140
 
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL <--- input
Media recovery cancelled.
SQL> alter database open resetlogs;
 
Database altered.

11. create web console;

SQL> begin
  2  dbms_xdb.sethttpport('8080');
  3  end;
  4  /

PL/SQL 过程已成功完成。


12. create user:

CREATE USER TAD IDENTIFIED BY "123" DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;

GRANT DBA TO TAD;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值