{"id":2103,"date":"2021-01-28T19:06:47","date_gmt":"2021-01-28T19:06:47","guid":{"rendered":"https:\/\/swiv.com.br\/creating-oracle-database-manually-using-sqlplus\/"},"modified":"2026-05-27T20:02:52","modified_gmt":"2026-05-27T19:02:52","slug":"creating-oracle-database-manually-using-sqlplus","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2021\/01\/28\/creating-oracle-database-manually-using-sqlplus\/","title":{"rendered":"Creating Oracle Database manually (using SQL*Plus)"},"content":{"rendered":"\n<p>Como este \u00e9 apenas um ambiente de laborat\u00f3rio de estudos, vou criar apenas um diret\u00f3rio na m\u00e1quina que vai abrigar todos os arquivos ligados ao novo banco de dados:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 restore]$ mkdir BSS\n&#x5B;oracle@oel7 restore]$ chmod 775 BSS\/\n&#x5B;oracle@oel7 restore]$ cd BSS\/\n&#x5B;oracle@oel7 BSS]$ pwd\n\/restore\/BSS\n<\/pre><\/div>\n\n\n<p>Agora, o ideal \u00e9 setar todas as vari\u00e1veis de ambientes necess\u00e1rias. Farei isso direto no bash_profile do usu\u00e1rio oracle. Lembrando que estou utilizando um bin\u00e1rio j\u00e1 instalado do Oracle 12C:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 binarios]$ cd\n&#x5B;oracle@oel7 ~]$ vi .bash_profile\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# .bash_profile\n \n# Get the aliases and functions\nif &#x5B; -f ~\/.bashrc ]; then\n        . ~\/.bashrc\nfi\n \n# User specific environment and startup programs\n \nPATH=$PATH:$HOME\/bin\n \nexport PATH\n \nORACLE_SID=BSS\nORACLE_BASE=\/restore\/binarios\/\nORACLE_HOME=\/restore\/binarios\/12.2.0.1\nLD_LIBRARY_PATH=$ORACLE_HOME\/lib:\/lib:\/usr\/lib\nPATH=$ORACLE_HOME\/bin:$PATH\nNLS_LANG=American_America.WE8MSWIN1252\nNLS_NUMERIC_CHARACTERS=.,\nNLS_SORT=binary\nNLS_DATE_FORMAT=&#039;DD-MM-YYYY HH24:MI:SS&#039;\n \nexport ORACLE_SID ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH PATH NLS_LANG NLS_NUMERIC_CHARACTERS NLS_SORT NLS_DATE_FORMAT\n<\/pre><\/div>\n\n\n<p>Carregando o bash_profile:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ . .bash_profile\n&#x5B;oracle@oel7 ~]$ echo $ORACLE_SID; echo $ORACLE_HOME; echo $ORACLE_BASE\nBSS\n\/restore\/binarios\/12.2.0.1\n\/restore\/binarios\/\n&#x5B;oracle@oel7 ~]$\n<\/pre><\/div>\n\n\n<p>A pr\u00f3xima etapa \u00e9 escolher qual tipo de autentica\u00e7\u00e3o ser\u00e1 utilizada (por um password file ou via sistema operacional). Eu opto pela segunda.<\/p>\n\n\n\n<p>Depois, precisamos popular um arquivo pfile com par\u00e2metros m\u00ednimos, como no exemplo abaixo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 BSS]$ cd $ORACLE_HOME\/dbs\n&#x5B;oracle@oel7 dbs]$ vi init.ora\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb_name=&#039;BSS&#039;\nmemory_target=2G\nprocesses = 150\ndb_block_size=8192\ndb_recovery_file_dest=&#039;\/restore\/BSS&#039;\ndb_recovery_file_dest_size=2G\ndiagnostic_dest=&#039;\/restore\/BSS&#039;\ndispatchers=&#039;(PROTOCOL=TCP) (SERVICE=ORCLXDB)&#039;\nopen_cursors=300\nremote_login_passwordfile=&#039;EXCLUSIVE&#039;\nundo_tablespace=&#039;UNDOTBS1&#039;\ncontrol_files = (&#039;\/restore\/BSS\/controlfile.ctl1&#039;, &#039;\/restore\/BSS\/controlfile.ctl2&#039;)\ncompatible =&#039;12.0.0&#039;\n<\/pre><\/div>\n\n\n<p>Agora, podemos criar um SPFILE a partir do PFILE:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 dbs]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 15:23:12 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \nConnected to an idle instance.\n \nSQL&gt; CREATE SPFILE FROM PFILE=&#039;\/restore\/binarios\/12.2.0.1\/dbs\/init.ora&#039;;\n \nFile created.\n \nSQL&gt;\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 dbs]$ ls -lthr spfileBSS.ora\n-rw-r----- 1 oracle oinstall 1.5K Jan 28 15:23 spfileBSS.ora\n&#x5B;oracle@oel7 dbs]$\n<\/pre><\/div>\n\n\n<p>Inicializando a inst\u00e2ncia:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 dbs]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 15:26:28 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \nConnected to an idle instance.\n \nSQL&gt; startup nomount;\nORACLE instance started.\n \nTotal System Global Area 2147483648 bytes\nFixed Size                  8622776 bytes\nVariable Size            1291849032 bytes\nDatabase Buffers          838860800 bytes\nRedo Buffers                8151040 bytes\nSQL&gt; !ps -ef | grep pmon | grep BSS\noracle    7040     1  0 15:26 ?        00:00:00 ora_pmon_BSS\noracle    7143  6068  0 15:26 pts\/2    00:00:00 \/bin\/bash -c ps -ef | grep pmon | grep BSS\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Agora basta criar o banco de dados com o comando do exemplo abaixo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nCREATE DATABASE BSS\n   USER SYS IDENTIFIED BY BSS\n   USER SYSTEM IDENTIFIED BY BSS\n   LOGFILE GROUP 1 (&#039;\/restore\/BSS\/redo01a.log&#039;,&#039;\/restore\/BSS\/redo01b.log&#039;) SIZE 100M BLOCKSIZE 512,\n           GROUP 2 (&#039;\/restore\/BSS\/redo02a.log&#039;,&#039;\/restore\/BSS\/redo02b.log&#039;) SIZE 100M BLOCKSIZE 512,\n           GROUP 3 (&#039;\/restore\/BSS\/redo03a.log&#039;,&#039;\/restore\/BSSredo03b.log&#039;) SIZE 100M BLOCKSIZE 512\n   MAXLOGHISTORY 1\n   MAXLOGFILES 16\n   MAXLOGMEMBERS 3\n   MAXDATAFILES 1024\n   CHARACTER SET AL32UTF8\n   NATIONAL CHARACTER SET AL16UTF16\n   EXTENT MANAGEMENT LOCAL\n   DATAFILE &#039;\/restore\/BSS\/system01.dbf&#039;\n     SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED\n   SYSAUX DATAFILE &#039;\/restore\/BSS\/sysaux01.dbf&#039;\n     SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED\n   DEFAULT TABLESPACE users\n      DATAFILE &#039;\/restore\/BSS\/users01.dbf&#039;\n      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED\n   DEFAULT TEMPORARY TABLESPACE tempts1\n      TEMPFILE &#039;\/restore\/BSS\/temp01.dbf&#039;\n      SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED\n   UNDO TABLESPACE undotbs1\n      DATAFILE &#039;\/restore\/BSS\/undotbs01.dbf&#039;\n      SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED;\n<\/pre><\/div>\n\n\n<p>Resultado:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 BSS]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 15:30:29 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production\n \nSQL&gt; CREATE DATABASE BSS\n  2     USER SYS IDENTIFIED BY BSS\n  3     USER SYSTEM IDENTIFIED BY BSS\n  4     LOGFILE GROUP 1 (&#039;\/restore\/BSS\/redo01a.log&#039;,&#039;\/restore\/BSS\/redo01b.log&#039;) SIZE 100M BLOCKSIZE 512,\n  5             GROUP 2 (&#039;\/restore\/BSS\/redo02a.log&#039;,&#039;\/restore\/BSS\/redo02b.log&#039;) SIZE 100M BLOCKSIZE 512,\n  6             GROUP 3 (&#039;\/restore\/BSS\/redo03a.log&#039;,&#039;\/restore\/BSSredo03b.log&#039;) SIZE 100M BLOCKSIZE 512\n   MAXLOGHISTORY 1\n  7    8     MAXLOGFILES 16\n  9     MAXLOGMEMBERS 3\n   MAXDATAFILES 1024\n 10   11     CHARACTER SET AL32UTF8\n 12     NATIONAL CHARACTER SET AL16UTF16\n   EXTENT MANAGEMENT LOCAL\n 13   14     DATAFILE &#039;\/restore\/BSS\/system01.dbf&#039;\n     SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED\n 15   16     SYSAUX DATAFILE &#039;\/restore\/BSS\/sysaux01.dbf&#039;\n 17       SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED\n   DEFAULT TABLESPACE users\n 18   19        DATAFILE &#039;\/restore\/BSS\/users01.dbf&#039;\n 20        SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED\n 21     DEFAULT TEMPORARY TABLESPACE tempts1\n 22        TEMPFILE &#039;\/restore\/BSS\/temp01.dbf&#039;\n      SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED\n 23   24     UNDO TABLESPACE undotbs1\n 25        DATAFILE &#039;\/restore\/BSS\/undotbs01.dbf&#039;\n 26        SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED;\n \nDatabase created.\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Agora precisamos rodar os scripts que constroem o dicion\u00e1rio de dados do banco:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 BSS]$ cd $ORACLE_HOME\/rdbms\/admin\/\n&#x5B;oracle@oel7 BSS]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 15:30:29 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production\n \nSQL&gt; @catalog.sql\n \n&#x5B;...]\n \nPL\/SQL procedure successfully completed.\n \n \nTIMESTAMP\n--------------------------------------------------------------------------------\nCOMP_TIMESTAMP CATALOG    2021-01-28 15:37:20\n \n \nSession altered.\n \n \nSession altered.\n \nSQL&gt;\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; @catproc.sql\n \n&#x5B;...]\n \nSQL&gt; Rem *********************************************************************\nSQL&gt; Rem END catproc.sql\nSQL&gt; Rem *********************************************************************\nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Recompilando os objetos:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; @utlrp.sql\n \n&#x5B;...]\n \nSQL&gt; Rem ===========================================================================\nSQL&gt; Rem END utlrp.sql\nSQL&gt; Rem ===========================================================================\nSQL&gt;\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 admin]$ cd $ORACLE_HOME\/sqlplus\/admin\n&#x5B;oracle@oel7 admin]$ sqlplus SYSTEM as sysdba\n \nSQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 16:01:07 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \nEnter password:\n \nConnected to:\nOracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production\n \nSQL&gt; @pupbld.sql\n \nSession altered.\n \nDROP SYNONYM PRODUCT_USER_PROFILE\n             *\nERROR at line 1:\nORA-01434: private synonym to be dropped does not exist\n \n \n \nPL\/SQL procedure successfully completed.\n \nDROP VIEW PRODUCT_PRIVS\n*\nERROR at line 1:\nORA-00942: table or view does not exist\n \n \n \nView created.\n \n \nGrant succeeded.\n \nDROP PUBLIC SYNONYM PRODUCT_PROFILE\n                    *\nERROR at line 1:\nORA-01432: public synonym to be dropped does not exist\n \n \n \nSynonym created.\n \nDROP SYNONYM PRODUCT_USER_PROFILE\n             *\nERROR at line 1:\nORA-01434: private synonym to be dropped does not exist\n \n \n \nSynonym created.\n \nDROP PUBLIC SYNONYM PRODUCT_USER_PROFILE\n                    *\nERROR at line 1:\nORA-01432: public synonym to be dropped does not exist\n \n \n \nSynonym created.\n \n \nSession altered.\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Validando o banco de dados:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 admin]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 16:02:19 2021\n \nCopyright (c) 1982, 2016, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production\n \nSQL&gt; select instance_name,status from gv$instance;\n \nINSTANCE_NAME    STATUS\n---------------- ------------\nBSS              OPEN\n \nSQL&gt; ALTER SYSTEM CHECKPOINT;\n \nSystem altered.\n \nSQL&gt; exit\nDisconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production\n&#x5B;oracle@oel7 admin]$ rman target \/\n \nRecovery Manager: Release 12.2.0.1.0 - Production on Thu Jan 28 16:02:52 2021\n \nCopyright (c) 1982, 2017, Oracle and\/or its affiliates.  All rights reserved.\n \nconnected to target database: BSS (DBID=64177763)\n \nRMAN&gt; report schema;\n \nusing target database control file instead of recovery catalog\nReport of database schema for database with db_unique_name BSS\n \nList of Permanent Datafiles\n===========================\nFile Size(MB) Tablespace           RB segs Datafile Name\n---- -------- -------------------- ------- ------------------------\n1    700      SYSTEM               YES     \/restore\/BSS\/system01.dbf\n2    550      SYSAUX               NO      \/restore\/BSS\/sysaux01.dbf\n3    260      UNDOTBS1             YES     \/restore\/BSS\/undotbs01.dbf\n4    500      USERS                NO      \/restore\/BSS\/users01.dbf\n \nList of Temporary Files\n=======================\nFile Size(MB) Tablespace           Maxsize(MB) Tempfile Name\n---- -------- -------------------- ----------- --------------------\n1    20       TEMPTS1              32767       \/restore\/BSS\/temp01.dbf\n \nRMAN&gt;\n<\/pre><\/div>\n\n\n<p>Fonte:&nbsp;<a href=\"https:\/\/docs.oracle.com\/database\/121\/ADMIN\/create.htm#ADMIN-GUID-18B03451-5C74-4B53-A892-656C3E8A2556\">https:\/\/docs.oracle.com\/database\/121\/ADMIN\/create.htm#ADMIN-GUID-18B03451-5C74-4B53-A892-656C3E8A2556<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Como este \u00e9 apenas um ambiente de laborat\u00f3rio de estudos, vou criar apenas um diret\u00f3rio na m\u00e1quina que vai abrigar todos os arquivos ligados ao novo banco de dados: Agora, o ideal \u00e9 setar todas as vari\u00e1veis de ambientes necess\u00e1rias. Farei isso direto no bash_profile do usu\u00e1rio oracle. Lembrando que estou utilizando um bin\u00e1rio j\u00e1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[19],"class_list":["post-2103","post","type-post","status-publish","format-standard","hentry","category-administration","tag-oracle-database"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=2103"}],"version-history":[{"count":1,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2103\/revisions"}],"predecessor-version":[{"id":9264,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2103\/revisions\/9264"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=2103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=2103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=2103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}