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.

138 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> SchemasBEFORE INSERT OR UPDATE OR DELETE ON employeesEMPLOYEES CREATE TRIGGER update_job_his<strong>to</strong>ryAFTER UPDATE OF job_id, department_id ON employeesFOR EACH ROWThe equivalent syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> can be generated with the aid of Table 6.24.The commands <str<strong>on</strong>g>for</str<strong>on</strong>g> creating the secure_ employees and update_job_his<strong>to</strong>rytriggers will c<strong>on</strong>vert as:7.CREATE TRIGGER secure_employeesON employeesINSTEAD OF INSERT, UPDATE, DELETEAS…GOCREATE TRIGGER update_job_his<strong>to</strong>ryON employeesAFTER UPDATEAS…GOIF (UPDATE(job_id) or UPDATE(department_id))Create indexes.All indexes related <strong>to</strong> c<strong>on</strong>straints should have been created in Substep 5.b. Thisstep covers the indexes that are not related <strong>to</strong> any c<strong>on</strong>straints.The following query can be used <strong>to</strong> retrieve in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> indexes in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> thatare not related <strong>to</strong> any c<strong>on</strong>straints. This query will work <strong>on</strong>ly in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i becausethe data dicti<strong>on</strong>ary be<str<strong>on</strong>g>for</str<strong>on</strong>g>e this release of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does not have the columns used inthis query.SELECT i.table_name, i.index_name, c.column_name, i.uniqueness,i.tablespace_name, i.pct_freeFROM dba_indexes i, dba_ind_columns cWHERE i.table_name = c.table_nameAND i.index_name = c.index_nameAND i.owner = c.index_ownerAND i.owner = 'HR'AND (i.owner, i.index_name) NOT IN(SELECT index_owner, index_nameFROM dba_c<strong>on</strong>straintsWHERE owner = 'HR'AND index_name IS NOT NULL)ORDER BY i.table_name, i.index_name, c.column_positi<strong>on</strong>The output obtained has been <str<strong>on</strong>g>for</str<strong>on</strong>g>matted as follows:TABLE_NAME INDEX_NAMECOLUMN_NAMEUNIQUENESSTABLESPACE_NAMEPCT_FREEDEPARTMENTSDEPT_LOCATION_IX LOCATION_ID NONUNIQUEINDX 10EMPLOYEES EMP_DEPARTMENT_IXINDX 10EMPLOYEES EMP-JOB-IXINDX 10DEPARTMENT_IDJOB_IDNONUNIQUENONUNIQUE

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

Saved successfully!

Ooh no, something went wrong!