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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 115 To create a UNIQUE c<strong>on</strong>straint using T-<strong>SQL</strong>, use the following syntax:The <strong>on</strong>ly syntactic difference in the UNIQUE c<strong>on</strong>straint definiti<strong>on</strong> between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<strong>SQL</strong> <strong>Server</strong> is with the USING INDEX clause used <strong>to</strong> define the index that en<str<strong>on</strong>g>for</str<strong>on</strong>g>ces thec<strong>on</strong>straint. The USING INDEX clause of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has an equivalent in <strong>SQL</strong> <strong>Server</strong> and canbe used with both column and table c<strong>on</strong>straints. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> table c<strong>on</strong>straint isdescribed in Table 6.14.Table 6.14: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Defining UNIQUE C<strong>on</strong>straints in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<strong>SQL</strong> <strong>Server</strong><str<strong>on</strong>g>Oracle</str<strong>on</strong>g><strong>SQL</strong> <strong>Server</strong>CREATE TABLE table_nameCREATE TABLE table_name((column_name datatype,column_name datatype,…,…,[ CONSTRAINT c<strong>on</strong>straint_name ] [ CONSTRAINT c<strong>on</strong>straint_name ]UNIQUE ( column_name [, …] ) UNIQUE [ CLUSTERED | NONCLUSTERED ][ USING INDEX [ TABLESPACE( column_name [, …] )tablespace_name ][ WITH FILLFACTOR = fillfac<strong>to</strong>r ][ s<strong>to</strong>rage_definiti<strong>on</strong> ] ][ ON FILEGROUP { filegroup |DEFAULT } ]Primary Key C<strong>on</strong>straintPRIMARY KEY c<strong>on</strong>straints have all the characteristics of UNIQUE c<strong>on</strong>straints, with theadditi<strong>on</strong>al restricti<strong>on</strong> that all primary key columns be NOT NULL. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> creates aUNIQUE index and a NOT NULL c<strong>on</strong>straint <strong>to</strong> implement PRIMARY KEY c<strong>on</strong>straints.With <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i, an existing n<strong>on</strong>-unique index may be used <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce the primary keyc<strong>on</strong>straint. In <strong>SQL</strong> <strong>Server</strong>, if a clustered index does not already exist <strong>on</strong> the table, or an<strong>on</strong>clustered index is not explicitly specified, a unique, clustered index is created <strong>to</strong>en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce the PRIMARY KEY c<strong>on</strong>straint. The following procedures dem<strong>on</strong>strate that it is fareasier <strong>to</strong> use T-<strong>SQL</strong> than Enterprise Manager when it comes <strong>to</strong> creating a PRIMARYKEY c<strong>on</strong>straint. To create a primary key c<strong>on</strong>straint using Enterprise Manager, follow thesesteps:1. In the Table Designer, click and select the colum n(s) that are part of the primarykey (use the Ctrl key <str<strong>on</strong>g>for</str<strong>on</strong>g> this).2. Right-clic k anywhere al<strong>on</strong>g the selected column(s) and click Set Primary Key. Acheck mark appears next <strong>to</strong> the Set Primary Key opti<strong>on</strong>.3. A unique clustered in dex using the naming c<strong>on</strong>venti<strong>on</strong> PK_table_name isau<strong>to</strong>matically created by the system.4. The name and properties of the index can be changed from those assigned by thesystem through the Indexes/Keys pane of the Table and Index Propertieswindow. To create a primary key c<strong>on</strong>straint using T-<strong>SQL</strong>, use the following syntax:<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> differ <strong>on</strong>ly in the USING INDEX part of the PRIMARY KEYc<strong>on</strong>straint syntax. The syntax differs from the UNIQUE c<strong>on</strong>straint definiti<strong>on</strong> <strong>on</strong>ly in theUNIQUE keyword being replaced with PRIMARY KEY. In both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, aNOT NULL c<strong>on</strong>straint is added by the system <str<strong>on</strong>g>for</str<strong>on</strong>g> all primary key columns when <strong>on</strong>e is notexplicitlyspecified.

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

Saved successfully!

Ooh no, something went wrong!