If you want to use a sequence to automatically popluate the column at each insert, you can alter the column to support this with the below syntax:
ALTER TABLE myschema.mytable ALTER COLUMN id SET DEFAULT nextval('myschema.mysequence'::regclass);
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
ALTER TABLE myschema.mytable ALTER COLUMN id SET DEFAULT nextval('myschema.mysequence'::regclass);
#!/bin/bash
export SCRIPT_NAME=`basename $0`
export TS=`date +\%m.\%d.\%y\_%H_%M_%S`
export GLOGFILE=/u01/mylogfile_${TS}.log
touch ${GLOGFILE}
chmod 666 ${GLOGFILE}
exec 1> ${GLOGFILE} 2>&1
echo "Starting job at " `date`
your shell instructions here
echo "Ending job at " `date`
exit
CREATE TABLE MYTABLE ( MYID NUMBER GENERATED ALWAYS AS IDENTITY ( START WITH 21 MAXVALUE 9999999999999999999999999999 MINVALUE 1 NOCYCLE CACHE 20 NOORDER NOKEEP NOSCALE) NOT NULL, EVENT_TYPE VARCHAR2(75 BYTE) NOT NULL, SOURCE VARCHAR2(50 BYTE) NOT NULL, FORMAT VARCHAR2(75 BYTE) NOT NULL, EVKEY VARCHAR2(60 BYTE) NOT NULL, TITLE VARCHAR2(40 BYTE) NOT NULL, TIMESTAMP TIMESTAMP(6) DEFAULT current_timestamp, DOCUMENT CLOB NOT NULL, FILEREF VARCHAR2(200 BYTE) DEFAULT 'some text' NOT NULL, TRANNUM NUMBER ) LOB (DOCUMENT) STORE AS SECUREFILE ( TABLESPACE LOB_DATA ) TABLESPACE DATA;After import, the developers tested an insert and the row was inserted with MYID set to 1.
select "ISEQ$$_88174".nextval from dual;To "start where the sequence left off" in the source database, all I had to do was to execute:
ALTER TABLE MYTABLE MODIFY (MYID GENERATED ALWAYS AS IDENTITY ( START WITH LIMIT VALUE) );
select max(MYID) from MYTABLE;And it returned 10632546, in other words, the next value would be the current max value + 1.
grant select on foreing_schema.foreign_table to scott with grant option;
lsnrctl status cdb Service "sales" has 2 instance(s). Instance "cdb", status READY, has 2 handler(s) for this service... Instance "sales", status UNKNOWN, has 1 handler(s) for this service...There is only one instance in my setup, the container database called "cdb".
SID_LIST_cdb = (SID_LIST = (SID_DESC = (ORACLE_HOME= /u01/orasoft/product/19c) (SID_NAME = sales) ) )
(SID_NAME = sales)and restart the listener, the extra instance will be removed from the listener output:
lsnrctl stop cdb lsnrctl start cdb
Service "sales" has 1 instance(s). Instance "cdb", status READY, has 2 handler(s) for this service...
GGSCI (myserver1.oric.no) 7> dblogin useridalias mydb domain admin ERROR: OCI Error DPI (status = 7-DPI-007: invalid OCI handle or descriptor).Cause:
names.default_domain = worldtnsnames.ora
mydb = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myserver1.oric.no)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = mydb) ) )To correct the error, you need to do either of the following:
mydb.world =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myserver1.oric.no)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mydb)
)
)
SELECT NAME,CAUSE,TYPE,MESSAGE,STATUS FROM PDB_PLUG_IN_VIOLATIONS WHERE NAME='PDB$SEED'
NAME | CAUSE | TYPE | MESSAGE | STATUS |
---|---|---|---|---|
PDB$SEED | SQL Patch | ERROR | Interim patch 31424070/24854845 (APPSST19C XTTS PDB - TABLE IMPORT/CREATION FAILED WITH ORA-39083 ORA-14334): Installed in the CDB but not in the PDB | RESOLVED |
PDB$SEED | SQL Patch | ERROR | Interim patch 34086870/24803071 (OJVM RELEASE UPDATE: 19.16.0.0.220719 (34086870)): Not installed in the CDB but installed in the PDB | RESOLVED |
PDB$SEED | SQL Patch | ERROR | '19.16.0.0.0 Release_Update 2207030222' is installed in the CDB but no release updates are installed in the PDB | RESOLVED |
PDB$SEED | SQL patch error | ERROR | Interim patch 34086870/24803071 (OJVM RELEASE UPDATE: 19.16.0.0.220719 (34086870)): ROLLBACK with status INITIALIZE in the CDB. | RESOLVED |
SYS@CDB$ROOT SQL> exec DBMS_PDB.CLEAR_PLUGIN_VIOLATIONS( pdb_name => 'PDB$SEED');
Database option DV mismatch: PDB installed version NULL. CDB installed version 19.0.0.0.0.which can be ignored. Read more about Database option mismatch errors in Doc ID 2020172.1