如何在oracle XE中创建数据库?

时间:2012-05-25 08:19:35

标签: java database oracle

在oracle XE中,有一个预安装的数据库,关于员工和部门等等,但我想创建一个新的数据库,我知道我可以在命令行中完成,但我查了数据库主页,我只发现创建表,在GUI或浏览器中,我需要创建自己的数据库,并使一个只能访问该数据库而不是员工数据库的用户

5 个答案:

答案 0 :(得分:12)

  

我认为你的意思是"架构"而不是"数据库"。安装程序创建名为XE的数据库,该数据库内部是名为HR的模式。要创建其他模式,您可以使用任何Oracle工具,如SQL Plus或Database Control,您所要做的就是创建一个新的用户帐户(因为user = schema)。但是,Oracle可能比SQL Plus更喜欢的是您访问XE" Home Page"在计算机上使用他们放在Win2K桌面上的快捷方式,然后单击“管理”链接

在此处阅读更多内容:http://www.dbforums.com/oracle/1605421-creating-new-db-express-edition.html

答案 1 :(得分:3)

以下是文本模式中的步骤,其中img-snapshots被丢弃......

'''先决条件:应具有管理员权限

'''本文档仅涵盖Microsoft Windows版本的Oracle XE

'''我已经为Oracle XE 11g做了这个....我希望所有版本的Oracle XE都一样....

1)安装Oracle XE

2)确保您记下了在安装过程中提供的系统密码。

3)安装完成后,单击Start Database

启动Oracle XE服务

4)打开oracle web仪表板, - 单击“入门”页面。

5)在网络信息中心中创建新用户。

a.  In the Getting Started web page, click on – “Application Express”

b.  Login as system user

c.  Now create new-user under Application Express, give the db-username,application-express-user-name as same for convenience.

6)创建db_user后,打开sql_plus

7)connect sys as sysdba并提供system用户密码,

8)将sysdba角色授予created-db

grant sysdba to {database};例如grant sysdba to pcbscheduler;

9)现在你已经完成了在XE中创建新数据库(因为它限制了。)

10)尝试从Oracle SQL Developer进行连接。

答案 2 :(得分:1)

我有这个链接给你。 Go through it
你觉得它有用吗。

编辑:我已更改链接,请再次参考...

答案 3 :(得分:1)

在oracle xe中我发现它有点奇怪;你必须创建一个用户。以该用户身份登录,然后您可以创建数据库对象。

您可以从所谓的数据库主页进行此操作;如果你想真正探索你的选择;在您创建用户之后;你可以安装sql developer并与之连接;它对我来说更直观。

答案 4 :(得分:0)

将以下代码保存在批处理文件中(例如createOraDbWin.bat)。更改app_name,ora_dir等参数值,使用管理权限运行文件。批处理文件创建一个基本的oracle数据库:

注意:可能需要很长时间(根据资源可用性大约30分钟)

REM ASSUMPTIONS
rem oracle xe has been installed
rem oracle_home has been set
rem oracle_sid has been set
rem oracle service is running

REM SET PARAMETERS
set char_set =al32utf8
set nls_char_set =al16utf16

set ora_dir=d:\app\db\oracle
set version=11.2.0.0
set app_name=xyz
set db_name=%app_name%_db
set db_sid=%db_name%_sid
set db_ins=%db_name%_ins
set sys_passwd=x3y5z7
set system_passwd=1x4y9z

set max_log_files=32
set max_log_members=4
set max_log_history=100
set max_data_files=254
set max_instances=1

set version_dir=%ora_dir%\%version%
set db_dir=%version_dir%\%db_name%

set instl_temp_dir=%db_dir%\instl\script

set system_dir=%db_dir%\system
set user_dir=%db_dir%\user
set undo_dir=%db_dir%\undo
set sys_aux_dir=%db_dir%\sysaux
set temp_dir=%db_dir%\temp
set control_dir=%db_dir%\control

set pfile_dir=%db_dir%\pfile
set data_dir=%db_dir%\data
set index_dir=%db_dir%\index
set log_dir=%db_dir%\log
set backup_dir=%db_dir%\backup
set archive_dir=%db_dir%\archive

set data_dir=%db_dir%\data
set index_dir=%db_dir%\index
set log_dir=%db_dir%\log
set backup_dir=%db_dir%\backup
set archive_dir=%db_dir%\archive
set undo_dir=%db_dir%\undo
set default_dir=%db_dir%\default

set system_tbs=%db_name%_system_tbs
set user_tbs=%db_name%_user_tbs
set sys_aux_tbs=%db_name%_sys_aux_tbs
set temp_tbs=%db_name%_temp_tbs
set control_tbs=%db_name%_control_tbs

set data_tbs=%db_name%_data_tbs
set index_tbs=%db_name%_index_tbs
set log_tbs=%db_name%_log_tbs
set backup_tbs=%db_name%_backup_tbs
set archive_tbs=%db_name%_archive_tbs
set undo_tbs=%db_name%_undo_tbs
set default_tbs=%db_name%_default_tbs

set system_file=%system_dir%\%db_name%_system.dbf
set user_file=%user_dir%\%db_name%_user.dbf
set sys_aux_file=%sys_aux_dir%\%db_name%_sys_aux.dbf
set temp_file=%temp_dir%\%db_name%_temp.dbf
set control_file=%control_dir%\%db_name%_control.dbf

set data_file=%data_dir%\%db_name%_data.dbf
set index_file=%index_dir%\%db_name%_index.dbf
set backup_file=%backup_dir%\%db_name%_backup.dbf
set archive_file=%archive_dir%\%db_name%_archive.dbf
set undo_file=%undo_dir%\%db_name%_undo.dbf
set default_file=%default_dir%\%db_name%_default.dbf

set log1_file=%log_dir%\%db_name%_log1.log
set log2_file=%log_dir%\%db_name%_log2.log
set log3_file=%log_dir%\%db_name%_log3.log

set init_file=%pfile_dir%\init%db_sid%.ora
set db_create_file=%instl_temp_dir%\createdb.sql
set db_drop_file=dropdb.sql

set db_create_log=%instl_temp_dir%\db_create.log
set db_drop_log=db_drop.log

set oracle_sid=%db_sid%

REM WRITE DROP DATABASE SQL COMMANDS TO FILE
echo shutdown immediate;>%db_drop_file%
echo startup mount exclusive restrict;>>%db_drop_file%
echo drop database;>>%db_drop_file%

REM EXECUTE DROP DATABASE SQL COMMANDS FROM THE FILE    
rem sqlplus -s "/as sysdba" @"%db_drop_file%">%db_drop_log%

REM DELETE WINDOWS ORACLE SERVICE
rem oradim -delete -sid %db_sid%

REM CREATE DIRECTORY STRUCTURE
md %system_dir%
md %user_dir%
md %sys_aux_dir%
md %temp_dir%
md %control_dir%

md %pfile_dir%
md %data_dir%
md %index_dir%
md %log_dir%
md %backup_dir%
md %archive_dir%
md %undo_dir%
md %default_dir%
md %instl_temp_dir%

REM WRITE INIT FILE PARAMETERS TO INIT FILE
echo db_name='%db_name%'>%init_file%
echo memory_target=1024m>>%init_file%
echo processes=150>>%init_file%
echo sessions=20>>%init_file%
echo audit_file_dest=%user_dir%>>%init_file%
echo audit_trail ='db'>>%init_file%
echo db_block_size=8192>>%init_file%
echo db_domain=''>>%init_file%
echo diagnostic_dest=%db_dir%>>%init_file%
echo dispatchers='(protocol=tcp) (service=%app_name%xdb)'>>%init_file%
echo shared_servers=4>>%init_file%
echo open_cursors=300>>%init_file%
echo remote_login_passwordfile='exclusive'>>%init_file%
echo undo_management=auto>>%init_file%
echo undo_tablespace='%undo_tbs%'>>%init_file%
echo control_files = ("%control_dir%\control1.ora", "%control_dir%\control2.ora")>>%init_file%
echo job_queue_processes=4>>%init_file%
echo db_recovery_file_dest_size = 10g>>%init_file%
echo db_recovery_file_dest=%log_dir%>>%init_file%
echo compatible ='11.2.0'>>%init_file%

REM WRITE DB CREATE AND ITS RELATED SQL COMMAND TO FILE    
echo startup nomount pfile='%init_file%';>>%db_create_file%
echo.>>%db_create_file%

echo create database %db_name%>>%db_create_file%
echo user sys identified by %sys_passwd%>>%db_create_file%
echo user system identified by %system_passwd%>>%db_create_file%
echo logfile group 1 ('%log1_file%') size 100m,>>%db_create_file%
echo group 2 ('%log2_file%') size 100m,>>%db_create_file%
echo group 3 ('%log3_file%') size 100m>>%db_create_file%
echo maxlogfiles %max_log_files%>>%db_create_file%
echo maxlogmembers %max_log_members%>>%db_create_file%
echo maxloghistory %max_log_history%>>%db_create_file%
echo maxdatafiles %max_data_files%>>%db_create_file%
echo character set %char_set %>>%db_create_file%
echo national character set %nls_char_set %>>%db_create_file%
echo extent management local>>%db_create_file%
echo datafile '%system_file%' size 325m reuse>>%db_create_file%
echo sysaux datafile '%sys_aux_file%' size 325m reuse>>%db_create_file%
echo default tablespace %default_tbs%>>%db_create_file%
echo datafile '%default_file%'>>%db_create_file%
echo size 500m reuse autoextend on maxsize unlimited>>%db_create_file%
echo default temporary tablespace %temp_tbs%>>%db_create_file%
echo tempfile '%temp_file%'>>%db_create_file%
echo size 20m reuse>>%db_create_file%
echo undo tablespace %undo_tbs%>>%db_create_file%
echo datafile '%undo_file%'>>%db_create_file%
echo size 200m reuse autoextend on maxsize unlimited;>>%db_create_file%
echo.>>%db_create_file%

echo @?\rdbms\admin\catalog.sql>>%db_create_file%
echo.>>%db_create_file%

echo @?\rdbms\admin\catproc.sql>>%db_create_file%
echo.>>%db_create_file%

echo create spfile from pfile='%init_file%';>>%db_create_file%
echo.>>%db_create_file%

echo shutdown immediate;>>%db_create_file%
echo.>>%db_create_file%

echo startup;>>%db_create_file%
echo.>>%db_create_file%

echo show parameter spfile;>>%db_create_file%
echo.>>%db_create_file%

REM CREATE WINDOWS ORACLE SERVICE
oradim -new -sid %db_sid% -startmode auto

REM EXECUTE DB CREATE SQL COMMANDS FROM FILE
sqlplus -s "/as sysdba" @"%db_create_file%">%db_create_log%

pause

欢迎您的更正和改进!