views:

1289

answers:

5

I can understand that many years ago there would be this kind of limitation, but nowadays surely this limit could easily be increased. We have naming conventions for objects, but there is always a case that turns up where we hit this limit - especially in naming foreign keys.

Does anybody actually know why this isn't a bigger size - or is it bigger in 11g?


Apparently the answer is that it will break currently scripts that aren't defensively coded. I say that is a very worrying thing, Oracle is trying to be the database, surely this is the kind of thing that you must constantly improve, otherwise your product will die the death of a thousand cuts.

Whenever I see this kind of objection in-house, I think it is time to bite the bullet and sort it out. If people are running scripts that they do not check or maintain when they upgrade Oracle versions, then let them suffer the consequences of that choice. Provide them a compatibility flag, up the size to 4000, then save me the wasted time when I'm creating objects of having to constantly count to 30 to check the name is 'OK'.

+9  A: 

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%5Fstandard%5Fsql001.htm

(Looking for a ref)

cagcowboy
Wow - good answer. I've tried looking at the SQL-92 standard but cant actually find this part - do you know of the exact statement that defines this (teach a man to fish, and all that)
Chris Gill
Hmm, that's not how I read that document. It says to me that F391 is an item in the SQL/Foundation spec (whatever that is), and that Oracle has partial support for it, with a 30 character limit.
skaffman
I'd guess SQL/Foundation is one part of the SQL standard. I agree. From the title of the section, the 30 character limit seems to be the reason why oracle does NOT comply to that spec. (Or only partially)
Jens Schauder
Partially compliance. What a joke. "our screws partially comply to the metric standards, except they are not metric."
Jens Schauder
I haven't read the F391 spec in detail, but I'm assuming (maybe incorrectly) that "Long identifiers" means an increase in identifier length from 30 to 128. So saying that you "partially" support this by allowing 30 characters is a bit cheeky. You don't support the new standard, you still support the old standard (albeit 25% of the way to the new standard) Did that make sense?!!?
cagcowboy
No - it didn't make sense. But I think I understand the business speak
Chris Gill
+7  A: 

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.

Justin Cave
+1 This is almost certainly one of Oracle's many legacy design cripples.
skaffman
Surely its time to grow a pair and increase it - add a flag so that DBAs can refine it back down to 30. Legacy issues like this should always be confronted and sorted otherwise you end up crippling the whole code base, and people will just move onto something else
Chris Gill
+1 Am sure this is part of the reason. I'm sure I'll have coded VARCHAR2(30) somewhere...
cagcowboy
Not just millions of lines of DBA written code, but plenty of oracle internal code no doubt too. This topic came up in a session with steven feuerstein and he said he didn't think they would ever change it.
Matthew Watson
They couldn't exactly trumpet it as a new feature, either... they'd spend a lot of time extending the limit, and then announce "you can now use names longer than 30 characters!". They'd be the laughing stock.
skaffman
+1  A: 

Constraint violations get reported in SQLERRM which is limited to 255 characters, and which most clients use to make errors visible. I suspect increasing the allowable size of constraint names significantly would impact the ability to report on the violations (especially where a constraint violation has been bubbled up through a few layers of PL/SQL code).

Gary
So, uh, make that table wider, then?
skaffman
It isn't a table, but how client software actually gets errors from the database.
Gary
+2  A: 

ok, the limitation exists....

but do you really NEED more than to 30 character to name a table/index/column??

when writing queries, with that limitation I STILL find some column/table names annoying. If the limit were higher I might run into tables that required a query like:

select unique_identifier_column, 
time_when_the_user_remembered_to_change_the_row_in_the_receipt_table, 
foreign_key_to_the_ap_invoice_distributions_history_table_related_to_the_all_rows_table 
from ap_invoices_really_really_all_all_rows_present_in_this_ebs_table.

I apologize for the huge words :P

It would be nice to be able to name foreign keys with the names of both tables and columns they join - therefore when a foreign key exception is thrown you don't have to look up the columns that caused the failure. Then again Oracle could just tell you that info...
Chris Gill
A: 

I believe that the 30 character identifier length comes from COBOL which was standardised in the late 1950s. Since COBOL programs were the main user of SQL (and SEQUEL before that (and QUEL before that)), this must have seemed like a reasonable number for the identifier length.

Michael Dillon
I believe the first version of Oracle was written in Fortran, which I think has an identifier length limit of 31. Maybe that's relevant.
David Aldridge