The maximum number of columns in a table

Problem 1: what is the maximum number of columns we can have in a table

Problem 2: what is the maximum number of columns we should have in the table

+5
source share
5 answers

SQL 2000: 1024

SQL 2005: 1024

SQL 2008: 1024 for a non-wide table, 30k for a wide table.

Wide tables are designed to take advantage of the new sparse column function in SQL 2008, which is designed for cases where you have a large number of columns that are usually empty.

, , , , , , 1 2 ..

+7

1: , , , , .

2: , .

, , . , . , , . . subtotal1, subtotal2, subtotal3 ..

, , , . .

CREATE TABLE Subtotals (
  entity_id    INT NOT NULL,
  year_quarter SMALLINT NOT NULL, -- e.g. 20094
  subtotal NUMERIC(9,2) NOT NULL,
  PRIMARY KEY (entity_id, year_quarter),
  FOREIGN KEY (entity_id) REFERENCES Entities (entity_id)
);

:

MySQL

, .

+9

1) http://msdn.microsoft.com/en-us/library/aa933149%28SQL.80%29.aspx

1024 - .

2) 1024:). , , . , , - (). , (, person_address). , -, .

+1

2) . , . . , . , :

  • A (), / B
  • . , . , A, B, , .

Database design is an art, not a science. While recommendations and technical limitations will help you in the right direction, there are no hard and fast rules that will make your system work or crash 100%.

+1
source
  • I think 4096 in mysql, SQL Server I don't know
  • I asked the same question a few months ago in a special scenario, maybe the answers will help you solve it. Usually, as little as possible, I would say.
0
source

All Articles