IBM Books

SQL Reference


Appendix A. SQL Limits

The following tables describe certain SQL limits. Adhering to the most restrictive case can help the programmer design application programs that are easily portable.

Table 26. Identifier Length Limits
  Description Limit in Bytes
1 Longest authorization name (can only be single-byte characters) 8
2 Longest constraint name 18
3 Longest correlation name 128
4 Longest cursor name 18
5 Longest external program name 8
6 Longest host identifier a 255
7 Longest schema name 8
8 Longest server (database alias) name 8
9 Longest statement name 18
10 Longest unqualified column name 30
11 Longest unqualified package name 8
12 Longest unqualified user-defined type, user-defined function, stored procedure, buffer pool, table space, nodegroup, trigger, index, or index specification name 18
13 Longest unqualified table name, view name, nickname, or alias 128
14 Longest wrapper name 128
15 Longest identifier of a data source user (remote-authorization-name) 30
16 Longest password to access a data source 32
17 Longest data source name 18
18 Longest data source table name (remote-table-name) 128
19 Longest data source column name 128
20 Longest data source index name 128
Notes:

a
Individual host language compilers may have a more restrictive limit on variable names.

Table 27. Numeric Limits
  Description Limit
1 Smallest INTEGER value -2 147 483 648
2 Largest INTEGER value +2 147 483 647
3 Smallest BIGINT value -9 223 372 036 854 775 808
4 Largest BIGINT value +9 223 372 036 854 775 807
5 Smallest SMALLINT value -32 768
6 Largest SMALLINT value +32 767
7 Largest decimal precision 31
8 Smallest DOUBLE value -1.79769E+308
9 Largest DOUBLE value +1.79769E+308
10 Smallest positive DOUBLE value +2.225E-307
11 Largest negative DOUBLE value -2.225E-307
12 Smallest REAL value -3.402E+38
13 Largest REAL value +3.402E+38
14 Smallest positive REAL value +1.175E-37
15 Largest negative REAL value -1.175E-37

Table 28. String Limits
  Description Limit
1 Maximum length of CHAR (in bytes) 254
2 Maximum length of VARCHAR (in bytes) 32 672
3 Maximum length of LONG VARCHAR (in bytes) 32 700
4 Maximum length of CLOB (in bytes) 2 147 483 647
5 Maximum length of GRAPHIC (in characters) 127
6 Maximum length of VARGRAPHIC (in characters) 16 336
7 Maximum length of LONG VARGRAPHIC (in characters) 16 350
8 Maximum length of DBCLOB (in characters) 1 073 741 823
9 Maximum length of BLOB (in bytes) 2 147 483 647
10 Maximum length of character constant 32 672
11 Maximum length of graphic constant 16 336
12 Maximum length of concatenated character string 2 147 483 647
13 Maximum length of concatenated graphic string 1 073 741 823
14 Maximum length of concatenated binary string 2 147 483 647
15 Maximum number of hex constant digits 16 336
16 Maximum size of a catalog comment (in bytes) 254

Table 29. Datetime Limits
  Description Limit
1 Smallest DATE value 0001-01-01
2 Largest DATE value 9999-12-31
3 Smallest TIME value 00:00:00
4 Largest TIME value 24:00:00
5 Smallest TIMESTAMP value 0001-01-01-00.00.00.000000
6 Largest TIMESTAMP value 9999-12-31-24.00.00.000000

Table 30. Database Manager Limits
  Description Limit
1 Most columns in a table g 1 012
2 Most columns in a view a 5 000
3 Maximum length of a row including all overhead b g 32 677
4 Maximum size of a table per partition (in gigabytes) c g 512
5 Maximum size of an index per partition (in gigabytes) 512
6 Most rows in a table per partition 4 x 109
7 Longest index key including all overhead (in bytes) 1 024
8 Most columns in an index key 16
9 Most indexes on a table 32 767 or storage
10 Most tables referenced in an SQL statement or a view storage
11 Most host variable declarations in a precompiled program c storage
12 Most host variable references in an SQL statement 32 767
13 Longest host variable value used for insert or update (in bytes) 2 147 483 647
14 Longest SQL statement (in bytes) 65 535
15 Most elements in a select listg 1 012
16 Most predicates in a WHERE or HAVING clause storage
17 Maximum number of columns in a GROUP BY clause g 1 012
18 Maximum total length of columns in a GROUP BY clause (in bytes)g 32 677
19 Maximum number of columns in an ORDER BY clause g 1 012
20 Maximum total length of columns in an ORDER BY clause (in bytes) g 32 677
21 Maximum size of an SQLDA (in bytes) storage
22 Maximum number of prepared statements storage
23 Most declared cursors in a program storage
24 Maximum number of cursors opened at one time storage
25 Most tables in an SMS table space 65 534
26 Maximum number of constraints on a table storage
27 Maximum level of subquery nesting storage
28 Maximum number of subqueries in a single statement storage
29 Most values in an INSERT statement g 1 012
30 Most SET clauses in a single UPDATE statement g 1 012
31 Most columns in a UNIQUE constraint (supported via a UNIQUE index) 16
32 Maximum combined length of columns in a UNIQUE constraint (supported via a UNIQUE index) (in bytes) 1 024
33 Most referencing columns in a foreign key 16
34 Maximum combined length of referencing columns in a foreign key (in bytes) 1 024
35 Maximum length of a check constraint specification (in bytes) 65 535
36 Maximum number of columns in a partitioning key e 500
37 Maximum number of rows changed in a unit of work storage
38 Maximum number of packages storage
39 Most constants in a statement storage
40 Maximum concurrent users of server d 64 000
41 Maximum number of parameters in a stored procedure 32 767
42 Maximum number of parameters in a user defined function 90
43 Maximum run-time depth of cascading triggers 16
44 Maximum number of simultaneously active event monitors 32
45 Maximum size of a regular DMS table space (in gigabytes)c g 512
46 Maximum size of a long DMS table space (in terabytes)c 2
47 Maximum size of a temporary DMS table space (in terabytes)c 2
48 Maximum number of databases per instance concurrently in use 256
49 Maximum number of concurrent users per instance 64 000
50 Maximum number of concurrent applications per database 1 000
51 Maximum depth of cascaded triggers 16
52 Maximum partition number 999
53 Most table objects in DMS table space f 51 000
54 Longest variable index key part (in bytes) 255
55 Maximum number of columns in a data source table or view that is referenced by a nickname 5 000
Notes:

a
This maximum can be achieved using a join in the CREATE VIEW statement. Selecting from such a view is subject to the limit of most elements in a select list.

b
The actual data for BLOB, CLOB, LONG VARCHAR, DBCLOB, and LONG VARGRAPHIC columns is not included in this count. However information about the location of that data does take up some space in the row.

c
The numbers shown are architectural limits and approximations. The practical limits may be less.

d
The actual value will be the value of the MAXAGENTS configuration parameter. See the Administration Guide for information on MAXAGENTS.

e
This is an architectural limit. The limit on the most columns in an index key should be used as a practical limit.

f
Table objects include data, indexes, LONG VARCHAR/VARGRAPHIC columns, and LOB columns. Table objects that are in the same table space as the table data do not count extra toward the limit. However, each table object that is in a different table space than the table data does contribute one toward the limit for each table object type per table in the table space in which the table object resides.

g
For page size specific values please refer to Table 31.

Table 31. Database Manager Page Size Specific Limits
  Description 4K page size limit 8K page size limit 16K page size limit 32K page size limit
1 Most columns in a table 500 1 012 1 012 1 012
3 Maximum length of a row including all overhead 4 005 8 101 16 293 32 677
4 Maximum size of a table per partition (in gigabytes) 64 128 256 512
5 Maximum size of an index per partition (in gigabytes) 64 128 256 512
15 Most elements in a select list 500 1 012 1 012 1 012
17 Maximum number of columns in a GROUP BY clause 500 1 012 1 012 1 012
18 Maximum total length of columns in a GROUP BY clause (in bytes) 4 005 8 101 16 293 32 677
19 Maximum number of columns in an ORDER BY clause 500 1 012 1 012 1 012
20 Maximum total length of columns in an ORDER BY clause (in bytes) 4 005 8 101 16 293 32 677
29 Most values in an INSERT statement 500 1 012 1 012 1 012
30 Most SET clauses in a single UPDATE statement 500 1 012 1 012 1 012
45 Maximum size of a regular DMS table space (in gigabytes) 64 128 256 512


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]