Showing posts with label create database. Show all posts
Showing posts with label create database. Show all posts

Monday, September 08, 2014

ORA-01460 on PL/SQL Developer

An Oracle 9 database had the following character set:
 
SQL> l
  1  select sys_context('userenv','LANGUAGE')
  2* from dual
SQL> /
 
SYS_CONTEXT('USERENV','LANGUAGE')
----------------------------------------
ENGLISH_UNITED KINGDOM.WE8ISO8859P15
 
SQL>
 
I used PL/SQL Developer to look at the code in the database (as usual, click on the image to enlarge it and bring it into focus):

 
Somebody typed the following command in the database by mistake:
 
SQL> l
  1* create database sonar character set utf8
SQL> /
create database sonar character set utf8
*
ERROR at line 1:
ORA-01031: insufficient privileges
 
SQL>
 
I logged in to PL/SQL Developer again and found that I got an ORA-01460 when I tried to look at the same code in the database:


I also noticed that the database had a new character set:
 
SQL> l
  1  select sys_context('userenv','LANGUAGE')
  2* from dual
SQL> /
 
SYS_CONTEXT('USERENV','LANGUAGE')
----------------------------------------
ENGLISH_UNITED KINGDOM.UTF8
 
SQL>

I guess this is a bug as the user account which typed the create database command had no special privileges and Oracle replied with an ORA-01031. Therefore no damage should have been caused.

Three days later:

I logged in as a privileged user and tried to change the character set back but this failed, in line with the Oracle documentation:

SQL> conn / as sysdba
Connected.
SQL> alter database character set we8iso8859p15
  2  /
alter database character set we8iso8859p15
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set
 
SQL>
 
So, as a last resort, I logged back in with an ordinary user and tried to reverse the damage like this:
 
SQL> conn andrew/reid
Connected.
SQL> create database sonar character set we8iso8859p15
  2  /
create database sonar character set we8iso8859p15
*
ERROR at line 1:
ORA-01031: insufficient privileges
 
SQL>
 
This seemed to have the desired effect, at least in the short term as the character set went back to its original value:
 
SQL> select sys_context('userenv','LANGUAGE')
  2  from dual
  3  /
 
SYS_CONTEXT('USERENV','LANGUAGE')
----------------------------------------
AMERICAN_AMERICA.WE8ISO8859P15
 
SQL>
 
I will report back as the problem develops…

Thursday, March 13, 2014

ORA-13504

This was tested on Oracle 11.2.0.4. If you try to create a database like this i.e. without specifying a SYSAUX datafile clause:
 
create database extent management local
datafile '/database/NBAPERF/nba_system/system1.dbf'
size 100m autoextend on
logfile
group 1 ('/database/NBAPERF/nba_redo1/log1a.rdo',
         '/database/NBAPERF/nba_redo2/log1b.rdo') size 50m,
group 2 ('/database/NBAPERF/nba_redo1/log2a.rdo',
         '/database/NBAPERF/nba_redo2/log2b.rdo') size 50m
maxlogfiles 3
maxlogmembers 3
user sys identified by secret_password
user system identified by secret_password
default temporary tablespace temp
tempfile '/database/NBAPERF/nba_temp/temp1.dbf'
size 100m autoextend on
undo tablespace undotbs1
datafile '/database/NBAPERF/nba_system/undo1.dbf'
size 100m autoextend on
character set WE8ISO8859P1
/
 
Oracle will return an ORA-13504 and your database will not be created:
 
SQL>   2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20  create database extent management local
*
ERROR at line 1:
ORA-13504: No SYSAUX datafile clause specified
 
SQL>
 
You can stop this error occurring by specifying a SYSAUX datafile clause, as shown below:
 
create database extent management local
datafile '/database/NBAPERF/nba_system/system1.dbf'
size 100m autoextend on
sysaux datafile '/database/NBAPERF/nba_system/sysaux1.dbf'
size 100m autoextend on
logfile
group 1 ('/database/NBAPERF/nba_redo1/log1a.rdo',
         '/database/NBAPERF/nba_redo2/log1b.rdo') size 50m,
group 2 ('/database/NBAPERF/nba_redo1/log2a.rdo',
         '/database/NBAPERF/nba_redo2/log2b.rdo') size 50m
maxlogfiles 3
maxlogmembers 3
user sys identified by secret_password
user system identified by secret_password
default temporary tablespace temp
tempfile '/database/NBAPERF/nba_temp/temp1.dbf'
size 100m autoextend on
undo tablespace undotbs1
datafile '/database/NBAPERF/nba_system/undo1.dbf'
size 100m autoextend on
character set WE8ISO8859P1
/
 
… and the database will be created successfully:
 
SQL>   2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22
Database created.
 
SQL>

Friday, November 04, 2011

Maxlogfiles, maxlogmembers etc.

As far as I know, this information is accurate up to and including Oracle 9. When you run the create database command, you can specify various options e.g.
 
Maxlogfiles (the maximum number of redo log groups which the database may have).
Maxlogmembers (the maximum number of members allowed in each redo log group).
Etc.
 
To alter these values subsequently, you need to recreate the control file. Once the database has been created, you can find out what they were set to as follows. One way is to backup the control file:
 
SQL> alter database backup controlfile to trace;
 
Database altered.
 
SQL>
 
This will produce a trace file in user_dump_dest. If you go there straight away and do an ls –t|more (assuming your database is running on UNIX) the trace file will be the first name on the list (unless your database happens to be generating lots of trace files for some reason):
 
TEST9 > ls -t|more
andrew_ora_459234.trc
etc.
 
The value(s) you want will be in this file, just after the create controlfile statement:
 
CREATE CONTROLFILE REUSE DATABASE "ANDREW" RESETLOGS  NOARCHIVELOG
--  SET STANDBY TO MAXIMIZE PERFORMANCE
    MAXLOGFILES 16
    MAXLOGMEMBERS 2
    MAXDATAFILES 300
    MAXINSTANCES 1
    MAXLOGHISTORY 1470
 
If that is too long-winded, you can see the maxlogfiles setting like this:
 
SQL> select records_total
  2  from v$controlfile_record_section
  3  where type = 'REDO LOG'
  4  /
 
RECORDS_TOTAL
-------------
           16
 
SQL>
 
This SQL gives you maxlogmembers:
 
SQL> conn / as sysdba
Connected.
SQL> l
  1* select dimlm from x$kccdi
SQL> /
 
     DIMLM
----------
         2
 
SQL>
 
The value of maxdatafiles is here:
 
SQL> select records_total
  2  from v$controlfile_record_section
  3  where type = 'DATAFILE'
  4  /
 
RECORDS_TOTAL
-------------
          300
 
SQL>
 
The following query shows maxinstances:
 
  1  select records_total
  2  from v$controlfile_record_section
  3* where type = 'REDO THREAD'
SQL> /
 
RECORDS_TOTAL
-------------
            1
 
SQL>
 
And finally, here is maxloghistory:
 
  1  select records_total
  2  from v$controlfile_record_section
  3* where type = 'LOG HISTORY'
SQL> /
 
RECORDS_TOTAL
-------------
         1470
 
SQL>