To create a database in Oracle using the SQL command line, you'll need to use the *SQLPlus** tool. Here's a step-by-step guide:
-
Connect to the Oracle instance as a user with the necessary privileges:
sqlplus / as sysdba
-
Create the database using the CREATE DATABASE command:
CREATE DATABASE <database_name> CONTROLFILE = '/path/to/controlfile.ctl' DATAFILE = '/path/to/datafile.dbf' LOGFILE GROUP = 1 ('/path/to/logfile1.log'), GROUP = 2 ('/path/to/logfile2.log') CHARACTER SET AL32UTF8;
<database_name>
: Replace this with the desired name for your database./path/to/controlfile.ctl
: Specify the path to the control file, which contains metadata about the database./path/to/datafile.dbf
: Specify the path to the data file, which stores the actual data./path/to/logfile1.log
,/path/to/logfile2.log
: Specify the paths to the log files, which record database changes.- CHARACTER SET AL32UTF8: This sets the character set to support a wide range of characters.
-
Start the database:
STARTUP;
Example:
sqlplus / as sysdba
CREATE DATABASE my_database
CONTROLFILE = '/u01/app/oracle/product/12.2.0/dbhome_1/dbs/my_database.ctl'
DATAFILE = '/u01/app/oracle/product/12.2.0/dbhome_1/data/my_database.dbf'
LOGFILE GROUP = 1 ('/u01/app/oracle/product/12.2.0/dbhome_1/redo/my_database_1.log'), GROUP = 2 ('/u01/app/oracle/product/12.2.0/dbhome_1/redo/my_database_2.log')
CHARACTER SET AL32UTF8;
STARTUP;
Important Considerations:
- Ensure you have the necessary permissions to create databases.
- Choose appropriate paths for the control file, data file, and log files.
- The
CHARACTER SET
setting is crucial for supporting different character sets.