SQL Server varbinary(max) and varchar(max) data in a separate table

后端 未结 2 1700
难免孤独
难免孤独 2021-01-18 13:56

using SQL Server 2005 standard edition with SP2

I need to design a table where I will be storing a text file (~200KB) along with filename ,description and datetime.<

相关标签:
2条回答
  • 2021-01-18 14:22

    I can answer your question in one simple word: Kiss.

    Which of course stands for... Keep It Simple Stupid.

    Adding a table for is generally a no-no unless you really need one to solve a problem.

    Generally, I disagree with splitting tables. It adds complexity to databases and code. Having useless columns in a table is a bad thing, but it's not as bad as multiple tables when you only need one.

    Cases where you would consider adding another table:

    1. Some of your columns are BloB's of data (greater than page size) and they are rarely used and other columns with small data sizes are accessed frequently.
    2. If you lack a brain.
    3. If you are evil.
    4. Or... if you are trying to piss-off your coworkers.
    0 讨论(0)
  • 2021-01-18 14:24

    I would advise against separation. It complicates the design significantly for little or no benefit. As you probably know, SQL Server already stores LOBs on separate allocation units, as described in Table and Index Organization.

    Your first concern (separate filegroup allocation for the LOB data) can be addressed explicitly, as Mikael has already pointed out, by appropriately specifying the desired filegroup in the CREATE TABLE statement.

    Your second concern is no longer a concern with SQL Server 2012, see Online Index Operations for Indexes containing LOB columns. Even prior to SQL Server 2012 you could reorganize indexes with LOBs without problems (and REORGANIZE is online). Given that a full index rebuild is a very expensive operation (an online rebuild must be done at the table/index level, there is no partition online rebuild options), are you sure you want to complicate the design to accommodate for something that is, on one hand, seldom required, and on the other hand, will be available when you upgrade to SQL 2012?

    0 讨论(0)
提交回复
热议问题