How to create a small and simple database using Oracle 11 g and SQL Developer?

匿名 (未验证) 提交于 2019-12-03 02:51:02

问题:

How to create a small and simple database using Oracle 11 g and SQL Developer ? I am seeing too many errors and I cannot find any way to make a simple database. For example

create database company;  

Caused the following error:

Error starting at line 1 in command: create database company Error at Command Line:1 Column:0 Error report: SQL Error: ORA-01501: CREATE DATABASE failed ORA-01100: database already mounted 01501. 00000 -  "CREATE DATABASE failed" *Cause:    An error occurred during create database *Action:   See accompanying errors. 

EDIT- This is completely different from MySQL and MS-SQL that I am familiar with. Not as intuitive as I was expecting.

回答1:

First off, what Oracle calls a "database" is generally different than what most other database products call a "database". A "database" in MySQL or SQL Server is much closer to what Oracle calls a "schema" which is the set of objects owned by a particular user. In Oracle, you would generally only have one database per server (a large server might have a handful of databases on it) where each database has many different schemas. If you are using the express edition of Oracle, you are only allowed to have 1 database per server. If you are connected to Oracle via SQL Developer, that indicates that you already have the Oracle database created.

Assuming that you really want to create a schema, not a database (using Oracle terminology), you would create the user

CREATE USER company   IDENTIFIED BY <<password>>   DEFAULT TABLESPACE <<tablespace to use for objects by default>>   TEMPORARY TABLESPACE <<temporary tablespace to use>> 

You would then assign the user whatever privileges you wanted

GRANT CREATE SESSION TO company; GRANT CREATE TABLE TO company; GRANT CREATE VIEW TO company; ... 

Once that is done, you can connect to the (existing) database as COMPANY and create objects in the COMPANY schema.



回答2:

From your question description, I think you were to create a database schema, not a database instance. In Oracle terminology, a database instance is a set of files in the file system. It's more like data files in MySQL. Whereas database in MySQL is somewhat equivalent to Oracle's schema.

To create a schema in Oracle: https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_6014.htm

To create a database instance in Oracle (I personally prefer CDBA): https://docs.oracle.com/cd/E11882_01/server.112/e25494/create.htm#ADMIN11068

Notice the Oracle Express edition does not support mounting more than one database instance at one time.



回答3:

Actually the answer from Justin above could not be more incorrect. SQL Server and MySQL are for smallish databases. Oracle is for large enterprise databases, thus the difference in it's structure. And it is common to have more than one Oracle database on a server provided that the server is robust enough to handle the load. If you received the error posted above then you obviously are trying to create a new Oracle database and if you are doing that then you probably already understand the structure of an Oracle database. The likely scenario is that you attempted to create a database using dbca, it initially failed, but the binaries were created. You then adjusted your initial parameters and re-tried creating the database using dbca. However, the utility sees the binaries and folder structure for the database that you are creating so it thinks that the database already exists but is not mounted. Dropping the database and removing the binaries and folders as well as any other cleanup of the initial attempt should be done first, then try again.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!