Create Index equivalent from Oracle to SQL Server
Create Index equivalent from Oracle to SQL Server
I have a current index that I have pulled from Oracle and I am trying to add to SQL Server. As far as I can tell, I will have to remove the double quotes and use WITH(...
However, I cannot find the Maxtrans and other keywords equivalent in SQL Server, especially the M_ROW$$
, which I was thinking it would be the ROW_NUMBER
.
WITH(...
M_ROW$$
ROW_NUMBER
CREATE UNIQUE INDEX ""MYDB"".""I_SNAP$MYTABLE"" ON
""MYDB"".""MYTABLE"" (""M_ROW$$"")
PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE ""IL_MIS_INDX""
Any help will be greatly appreciated.
Thank you!
M_ROW$$
I_SNAP$MYTABLE
ROW_NUMBER
Those double-doublequotes aren't an Oracle thing. If you create a table named
XYZ
then tools tend to generate DDL as CREATE TABLE "SOMEUSER"."XYZ"
to be on the safe side, with all the storage defaults like PCTFREE 10 INITRANS 2 MAXTRANS 255
. Yes you can remove all double quotes unless they are explicitly preserving some non-standard name. MAXTRANS
is deprecated, and the other storage parameters are ignored anyway for automated segment space management, which has been the default for a long time.– William Robertson
Jun 29 at 23:12
XYZ
CREATE TABLE "SOMEUSER"."XYZ"
PCTFREE 10 INITRANS 2 MAXTRANS 255
MAXTRANS
By the way, it looks like
I_SNAP$MYTABLE
is a materialized view log, which appears not to have any equivalent in SQL Server. It's possible that it's not needed.– William Robertson
Jun 30 at 7:03
I_SNAP$MYTABLE
1 Answer
1
I'm guessing you don't need all the options. So, just use the default syntax:
CREATE UNIQUE INDEX <MYDB.I_SNAP$MYTABLE> ON MYDB.MYTABLE (<M_ROW$$>)
Of course, the table name and column name needs to be the actual names in SQL Server.
I am speculating that you don't need the index options in SQL Server. If you do, you will need to optimize the index for that database, rather than assuming that what works in Oracle will automatically work in SQL Server.
Gordon, Thank you for your answer. I was trying to keep the same structure in both environments. Of course, if that is not a possibility, I can definitely scale it down. However, if I can keep as close as possible, the better.
– 1moreLearner
Jun 29 at 19:03
What Gordon wrote preserves all logical structure, all other stuff is just options which are database engine dependant, may affect performace only and are not 1:1 portable
– avb
Jun 29 at 19:11
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
M_ROW$$
is the name of a column on the tableI_SNAP$MYTABLE
. As far as I can see it has no relation toROW_NUMBER
.– Bob Jarvis
Jun 29 at 19:47