Tutorial 5: Datatypes
The Oracle column datatypes need to be mapped to PostgreSQL datatypes.
The mappings themselves are documented in the Datatypes API page.
The salgrade1 table has been mapped to:
CREATE TABLE IF NOT EXISTS scott.salgrade1
(
salgrade1_id integer NOT NULL,
grade smallint,
losal bigint,
hisal numeric,
CONSTRAINT pk_salgrade1 PRIMARY KEY (salgrade1_id),
CONSTRAINT salgrade1_grade_check CHECK (grade < 100)
)
TABLESPACE pg_default;
The primary key
salgrade1_idhas been mapped toINTEGER.The
NUMBER(2,0)columngradehas been mapped toSMALLINT, with a check constraint.The
losalcolumn is aFLOAT, so maps toFLOAT.And the
hisalcolumn is aNUMBER, so maps toNUMERIC.
Standardise the
losalandhisaldatatypes.Using the
base.pytutorial script, add theCOLUMN_DATATYPESparameter.... parameters = { easyo2p.COLUMN_DATATYPES: [ 'SALGRADE1.LOSAL BIGINT', 'SALGRADE1.HISAL BIGINT' ], ...
Run the script.
Run the
base.pyscript. Once complete thelosalandhisalcolumns should have consistent datatypes.CREATE TABLE scott.SALGRADE1 ( SALGRADE1_ID INTEGER NOT NULL , GRADE SMALLINT CHECK (GRADE < 100) , LOSAL BIGINT , HISAL BIGINT ) TABLESPACE pg_default ;
Note
as PostgreSQL string columns are defined by the number of characters,
Consider using the COLUMN_DATATYPES parameter
if any Oracle character columns, that are defined as BYTE,
need their length adjusted.