12.07.2015 Views

Solution Guide for Migrating Oracle on UNIX to SQL Server - Willy .Net

Solution Guide for Migrating Oracle on UNIX to SQL Server - Willy .Net

Solution Guide for Migrating Oracle on UNIX to SQL Server - Willy .Net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

136 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> SchemasCREATE UNIQUE INDEX "HR"."LOC_ID_PK" ON"HR"."LOCATIONS" ("LOCATION_ID")PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGINGTABLESPACE "INDX" ;ALTER TABLE "HR"."LOCATIONS" ADD CONSTRAINT"LOC_ID_PK" PRIMARY KEY ("LOCATION_ID")USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGINGTABLESPACE "INDX" ENABLE;ALTER TABLE "HR"."LOCATIONS" ADD CONSTRAINT"LOC_C_ID_FK" FOREIGN KEY ("COUNTRY_ID")REFERENCES "HR"."COUNTRIES" ("COUNTRY_ID") ENABLE;c. C<strong>on</strong>vert the extracted <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DDL <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> syntax.In this step, the table DDL is c<strong>on</strong>verted al<strong>on</strong>g with c<strong>on</strong>straint and indexdefiniti<strong>on</strong>s. Foreign key c<strong>on</strong>straints are handled separately in the next step.Create clustered indexes be<str<strong>on</strong>g>for</str<strong>on</strong>g>e creating any n<strong>on</strong>-clustered indexes. Ifclustered indexes are planned <str<strong>on</strong>g>for</str<strong>on</strong>g> a table, defer creati<strong>on</strong> of n<strong>on</strong>clusteredindexes (as part of PRIMARY KEY or UNIQUE c<strong>on</strong>straint definiti<strong>on</strong>) during thetable creati<strong>on</strong> in this step.The first table in the example, COUNTRIES, is an index-organized table. For<strong>SQL</strong> <strong>Server</strong>, it is c<strong>on</strong>verted in<strong>to</strong> a heap with a clustered index <strong>on</strong> the primarykey, COUNTRY_ID.Note In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, there is a single datatype of the number variety which isc<strong>on</strong>strained with appropriate scale. While c<strong>on</strong>verting <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the datatype which is closest in scale needs <strong>to</strong> be used, as has been dem<strong>on</strong>strated inthe example.The following commands are used <strong>to</strong> create the COUNTRIES andLOCATIONS tables respectively.CREATE TABLE HR.COUNTRIES(COUNTRY_ID CHAR(2) CONSTRAINT NN_COUNTRY_ID NOT NULL,COUNTRY_NAME VARCHAR(40),REGION_ID NUMERIC,CONSTRAINT PK_COUNTRY_C_ID PRIMARY KEY CLUSTERED (COUNTRY_ID)ON HR_INDX)CREATE TABLE HR.LOCATIONS(LOCATION_ID SMALLINT NOT NULL,STREET_ADDRESS VARCHAR (40),POSTAL_CODE VARCHAR(12),CITY VARCHAR(30) CONSTRAINT NN_LOC_CITY NOT NULL,STATE_PROVINCE VARCHAR(25),COUNTRY_ID CHAR(2))ALTER TABLE HR. LOCATIONS ADD CONSTRAINTPK__ID PRIMARY KEY NONCLUSTERED (LOCATION_ID)ON HR_INDX

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!