문제

SQL 2016 - I have 2 tables, Foo & Bar - Bar references Foo. I'd like to turn Foo into an in-memory optimized table, however as Bar references this, I can't do it.

I also can't make Bar in-memory due to its dependence on Foo.

Seems like I need to do this to both tables at the same time - is this possible without recreating both tables from scratch?

도움이 되었습니까?

해결책

Seems like I need to do this to both tables at the same time

Correct. If you try to recreate the FK after migrating one table you will get:

Msg 10778, Level 16, State 0, Line 20
Foreign key relationships between memory optimized tables and non-memory optimized tables are not supported.

is this possible without recreating both tables from scratch?

Migrating to in-memory tables always requires recreating the tables from scratch. SSMS will rename your old tables, create the new in-memory tables, load them from your old tables, and drop your old tables.

다른 팁

Finally, I found one solution for foreign Key Table migrate to In-memory table. For that you need to open the disk-based table which contains key, script with drop and create option than put the comment on foreign key syntax than execute it. After that it's like normal table hence, you migrate it into In-Memory table, it'll successfully migrate in. Then re-open table script with Drop and Create option and remove comment than execute it. It'll create foreign key into In-memory table.

Note : Please take backup of all data before processed

I know this tedious process but that's only way I think

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top