Question:
How many records can an sql database hold?
Theodore
2011-10-26 16:08:59 UTC
My question is really simple, can I have a column with 1 trillion rows or more?
Three answers:
Ratchetr
2011-10-26 16:58:47 UTC
Columns don't have rows. Tables have rows. And columns.



MS-SQL and Oracle both list maximum rows per table as unlimited, or limited by available disk size. See links.



Not sure about MySQL. MyISAM may have, innodb may not. Would take more Googling to know for sure.



In practice, a 1 trillion row table, even if it only has 1 column isn't going to work very well. You'll need mulit-terabyte storage available to hold all that data. Any query that doesn't work off indexed columns (requires a full table scan) will take ages to complete.



When you get into large tables like that, you typically want to partition the data across multiple tables.



There are certainly many multi-terabyte databases around today. But there are none with a trillion rows in a single table. There are only 8 billion people in the world. Why would you need 125 rows for each person?



And suppose you could insert a million rows into this table in a single second. That's 1 row every microsecond. That's ***WAY*** beyond the capability of any machine today, hard drives just aren't that fast. But suppose you could. It would take you 694 days to insert a trillion rows. Scale the insert time down to what modern hardware can actually do today, do the math again, and I would guess it would take longer than computers have been around.



So...Yes. You can. In theory. But don't bother actually trying it.



ETA: The limits larrybud posted are specific to Microsoft's implementation of SQL. Other SQL engines have different limits. MS-SQL is only one of many SQL implementations. SQL itself has no limitations on anything, it's just a programming language definition.
TheMadProfessor
2011-10-27 06:24:32 UTC
As suggested by the previous answers, 'it depends' - mainly on the DBMS, tablespace limit and size of the row. However, most of the major DBMS have tablespace limits in the multi-TB range, so unless the rows contained LOBs or lots and lots of big VARCHAR columns, trillion+ row tables are probably quite possible (however, that many rows in a single table would be something of a red flag, indicating the database design might need as a serious looking at regarding normalization, data cleansing and/or an archival strategy.)
larrybud2004
2011-10-26 17:41:22 UTC
There are limits to a SQL database



Database size: 524,272 terabytes

Databases per instance of SQL Server: 32,767

Filegroups per database: 32,767

Files per database: 32,767

File size (data): 16 terabytes

File size (log): 2 terabytes

Rows per table: Limited by available storage

Tables per database: Limited by number of objects in a database


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...