Startup failing with ORA-14694 after running utl32k.sql in upgrade mode Here are the steps


Creating the db on Oracle 12c (12.2.0.1.0) 
Creating the admin views and tables 
Starting the db in upgrade mode and running utlk32.sql
Starting up is failing with these errors codes and messages


  ORA-00603: ORACLE server session terminated by fatal error
  ORA-01092: ORACLE instance terminated. Disconnection forced
  ORA-14694: database must in UPGRADE mode to begin MAX_STRING_SIZE migration


Can someone please help me to fix this 
The following are the detailed steps of the commands:

orapwd file=$ORACLE_HOME/dbs/pwdorclpdb1.ora password=mypwd entries=5
sqlplus /nolog
CONNECT / AS SYSDBA
startup nomount
SET SQLBLANKLINES ON


Create the database

CREATE DATABASE mydb
 USER SYS IDENTIFIED BY mypwd 
USER SYSTEM IDENTIFIED BY mypwd 
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/mydb/redo01.log') SIZE 100M, 
        GROUP 2  ('/u01/app/oracle/oradata/mydb/redo02.log') SIZE 100M, 
        GROUP 3 ('/u01/app/oracle/oradata/mydb/redo03.log') SIZE 100M 
MAXLOGFILES 5 
MAXLOGMEMBERS 5 
MAXLOGHISTORY 1 
MAXDATAFILES 100 
MAXINSTANCES 1 
CHARACTER SET AL32UTF8 
DATAFILE '/u01/app/oracle/oradata/mydb/system01.dbf' SIZE 325M REUSE
         AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED,
        '/u01/app/oracle/oradata/mydb/system02.dbf' SIZE 325M REUSE
         AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED, 
        '/u01/app/oracle/oradata/mydb/system03.dbf' SIZE 325M REUSE 
         AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED 
SYSAUX DATAFILE '/u01/app/oracle/oradata/mydb/sysaux01.dbf' SIZE 325M REUSE 
 AUTOEXTEND ON 
EXTENT MANAGEMENT LOCAL  
DEFAULT TABLESPACE def_t DATAFILE '/u01/app/oracle/oradata/mydb/def_t.dbf' 
  SIZE 100M REUSE AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED 
DEFAULT TEMPORARY TABLESPACE temp_t 
   TEMPFILE '/u01/app/oracle/oradata/mall/temp_t.dbf' SIZE 100M REUSE 
   AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED 
UNDO TABLESPACE wcs_undo_t 
   DATAFILE '/u01/app/oracle/oradata/mydb/undo_t.dbf' SIZE 200M REUSE 
   AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED;


Create dictionary tables and views

@$ORACLE_HOME/rdbms/admin/catalog.sql 
@$ORACLE_HOME/rdbms/admin/catproc.sql 
@$ORACLE_HOME/sqlplus/admin/pupbld.sql 


Create users

shutdown immediate
startup
alter session set "_ORACLE_SCRIPT"=true; 
CREATE USER user1 IDENTIFIED BY mypwd DEFAULT TABLESPACE def_t TEMPORARY TABLESPACE temp_t QUOTA UNLIMITED ON def_t;
GRANT CREATE PROCEDURE, CREATE SEQUENCE, CREATE SESSION, CREATE SYNONYM, 
CREATE TABLE, CREATE TRIGGER, CREATE VIEW, CREATE MATERIALIZED VIEW TO user1;


Apply Oracle12c extended type

PURGE DBA_RECYCLEBIN;
SHUTDOWN IMMEDIATE;
STARTUP UPGRADE;
ALTER SYSTEM SET MAX_STRING_SIZE=EXTENDED;
@?/rdbms/admin/utl32k.sql 
show parameter MAX_STRING_SIZE
NAME               TYPE        VALUE
------------------ ----------- --------------
max_string_size    string      EXTENDED

SHUTDOWN IMMEDIATE;


The issue - All previous commands were successful.

STARTUP;
ORACLE instance started. 
Total System Global Area 3221225472 bytes
Fixed Size                  8625856 bytes
Variable Size            2365587776 bytes
Database Buffers          838860800 bytes
Redo Buffers                8151040 bytes
Database mounted.
ORA-00603: ORACLE server session terminated by fatal error
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-14694: database must in UPGRADE mode to begin MAX_STRING_SIZE migration
Process ID: 20774
Session ID: 2 Serial number: 387
I figured it out
- PURGE DBA_RECYCLEBIN;
- CREATE SPFILE FROM PFILE = '$ORACLE_HOME/dbs/initorcl.ora';
- SHUTDOWN IMMEDIATE;
- startup mount;
- ALTER SYSTEM SET MAX_STRING_SIZE=EXTENDED SCOPE=SPFILE;
- shutdown;
- STARTUP UPGRADE;
- @?/rdbms/admin/utl32k.sql 
-show parameter MAX_STRING_SIZE
    NAME               TYPE        VALUE
    ------------------ ----------- --------------
    max_string_size    string      EXTENDED
- SHUTDOWN IMMEDIATE;
- STARUP;

Now startup is successful and max_string_size = EXTENDED