Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Oracle table/column/index names limited to 30 characters?

People also ask

What is the maximum length of column name in Oracle?

You're absolutely right: Table names are 30 characters maximum same as column names. No, don't believe so - but Oracle does.

What is the maximum length of an index name in Oracle?

Oracle limits all table names, partition names, index names, etc. to a maximum of thirty characters.

What is the maximum length allowed for a column in a table?

SQL maximum column name length limitation is 128 characters. If we create more than 128 characters, it shows an error. The total number of columns limitation is 1024.


I believe it's the ANSI standard.

EDIT:

Actually, I think it's the SQL-92 standard.

A later version of the standard appears to optionally allow for 128 character names, but Oracle doesn't yet support this (or has partial support for it, insofar as it allows 30 characters. Hmmm.)

Search for "F391, Long identifiers" on this page... http://stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/ap_standard_sql001.htm

(Looking for a ref)


In addition to cagcowboy's point that it derives from the SQL standard (historically, I suspect that Oracle's decision lead to the SQL standard since Oracle predated the standardization of SQL), I would wager that a large part of the reluctance to allow longer identifiers comes from the realization that there are millions of DBAs with millions of custom scripts that all assume that identifiers are 30 characters long. Allowing every line of code that goes something like

  l_table_name VARCHAR2(30);
BEGIN
  SELECT table_name
    INTO l_table_name
    FROM dba_tables
   WHERE ...

to suddenly break because the DBA 15 years ago used VARCHAR2(30) rather than DBA_TABLES.TABLE_NAME%TYPE in the script would cause massive revolt. I would wager that Oracle alone has thousands of places where this sort of thing has been done over the years in various packages and components. Retrofitting all that existing code to support longer identifiers would be a tremendous project that would almost certainly generate way more costs in developer time, QA time, and newly introduced bugs than it would generate benefits.


I was looking this up and found this question via Google, but also found out that as of Oracle 12c Release 2 (12.2), this is no longer strictly the case. (https://oracle-base.com/articles/12c/long-identifiers-12cr2)

At some point every DBA or developer will have hit a point where the 30 character limit for object names has caused a problem. This limit can be extremely painful when doing migration projects from SQL Server or MySQL to Oracle. In Oracle Database 12cR2, the maximum length of most identifiers is now 128 characters.

This is a new feature in 12.2, according to (http://blog.dbi-services.com/oracle-12cr2-long-identifiers/). According to that post, 12.1 was still limited to 30 characters.


Edit: Here's a link to the official Oracle documentation explaining the change. (https://docs.oracle.com/cloud/latest/exadataexpress-cloud/CSDBF/longer-identifier-names.htm#CSDBF-GUID-F4CA155F-5A37-4705-8443-0A8C9E3F875C)

Starting with Oracle Database 12c Release 2 (12.2), the maximum length of identifier names for most types of database objects has been increased to 128 bytes.


Given the practical necessity of identifier length limits, good design restricts the length of actual names to avoid hitting the ceiling when the names are combined with each other and with prefixes and suffixes.

For example, a convention of naming foreign key constraints

FK_<table1>_<table2> 

limits table names to 13 characters or less; most databases are going to need more prefixes and suffixes, further limiting the length of table names.