oracle Oracle中表名的最大长度是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/756558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 01:48:25  来源:igfitidea点击:

What is the maximum length of a table name in Oracle?

oraclename-length

提问by robertkroll

What are the maximum length of a table name and column name in Oracle?

Oracle中表名和列名的最大长度是多少?

回答by TStamper

In Oracle 12.2and above the maximum object name length is 128 bytes.

Oracle 12.2及更高版本中,最大对象名称长度为 128 字节。

In Oracle 12.1and below the maximum object name length is 30 bytes.

Oracle 12.1及以下版本中,最大对象名称长度为 30 字节。

回答by TStamper

Teach a man to fish

教人钓鱼

Notice the data-type and size

注意数据类型和大小

>describe all_tab_columns

VIEW all_tab_columns

Name                                      Null?    Type                        
 ----------------------------------------- -------- ----------------------------
 OWNER                                     NOT NULL VARCHAR2(30)                
 TABLE_NAME                                NOT NULL VARCHAR2(30)                
 COLUMN_NAME                               NOT NULL VARCHAR2(30)                
 DATA_TYPE                                          VARCHAR2(106)               
 DATA_TYPE_MOD                                      VARCHAR2(3)                 
 DATA_TYPE_OWNER                                    VARCHAR2(30)                
 DATA_LENGTH                               NOT NULL NUMBER                      
 DATA_PRECISION                                     NUMBER                      
 DATA_SCALE                                         NUMBER                      
 NULLABLE                                           VARCHAR2(1)                 
 COLUMN_ID                                          NUMBER                      
 DEFAULT_LENGTH                                     NUMBER                      
 DATA_DEFAULT                                       LONG                        
 NUM_DISTINCT                                       NUMBER                      
 LOW_VALUE                                          RAW(32)                     
 HIGH_VALUE                                         RAW(32)                     
 DENSITY                                            NUMBER                      
 NUM_NULLS                                          NUMBER                      
 NUM_BUCKETS                                        NUMBER                      
 LAST_ANALYZED                                      DATE                        
 SAMPLE_SIZE                                        NUMBER                      
 CHARACTER_SET_NAME                                 VARCHAR2(44)                
 CHAR_COL_DECL_LENGTH                               NUMBER                      
 GLOBAL_STATS                                       VARCHAR2(3)                 
 USER_STATS                                         VARCHAR2(3)                 
 AVG_COL_LEN                                        NUMBER                      
 CHAR_LENGTH                                        NUMBER                      
 CHAR_USED                                          VARCHAR2(1)                 
 V80_FMT_IMAGE                                      VARCHAR2(3)                 
 DATA_UPGRADED                                      VARCHAR2(3)                 
 HISTOGRAM                                          VARCHAR2(15)                

回答by robertkroll

DESCRIBE all_tab_columns

描述 all_tab_columns

will show a TABLE_NAME VARCHAR2(30)

将显示 TABLE_NAME VARCHAR2(30)

Note VARCHAR2(30) means a 30 byte limitation, not a 30 character limitation, and therefore may be different if your database is configured/setup to use a multibyte character set.

注意 VARCHAR2(30) 表示 30 字节限制,而不是 30 个字符限制,因此如果您的数据库配置/设置为使用多字节字符集,则可能会有所不同。

Mike

麦克风

回答by Maarten

Right, but as long as you use ASCII characters even a multibyte character set would still give a limitation of exactly 30 characters... so unless you want to put hearts and smiling cats in you're DB names your fine...

是的,但是只要您使用 ASCII 字符,即使是多字节字符集仍然会限制 30 个字符...

回答by Wild Pottok

30 char (bytes, really, as has been stated).

30 个字符(字节,真的,如前所述)。

But do not trust me; try this for yourself:

但不要相信我;自己试试这个:

SQL> create table I23456789012345678901234567890 (my_id number);

Table created.



SQL> create table I234567890123456789012345678901(my_id number);


ERROR at line 1:

ORA-00972: identifier is too long

Updated: as stated above, in Oracle 12.2 and later, the maximum object name length is now 128 bytes.

更新:如上所述,在 Oracle 12.2 及更高版本中,最大对象名称长度现在为 128 字节。

回答by Ian Carpenter

回答by fg78nc

On Oracle 12.2, you can use built-in constant, ORA_MAX_NAME_LEN, set to 128 bytes (as per 12.2) Prior to Oracle 12.1max size was 30 bytes.

在 上Oracle 12.2,您可以使用内置常量 ,ORA_MAX_NAME_LEN设置为 128 字节(根据 12.2) 在Oracle 12.1最大大小为 30 字节之前。

回答by Vaibhav

I'm working on Oracle 12c 12.1. However, doesn't seem like it allows more than 30 characters for column/table names.

我正在开发 Oracle 12c 12.1。但是,列/表名称似乎不允许超过 30 个字符。

Read through an oracle page which mentions 30 bytes. https://docs.oracle.com/database/121/SQLRF/sql_elements008.htm#SQLRF00223

通读一个提到 30 个字节的 oracle 页面。 https://docs.oracle.com/database/121/SQLRF/sql_elements008.htm#SQLRF00223

In 12c although the all_tab_columns do say VARCHAR2(128) for Table_Name, it does not allow more than 30 bytes name.

在 12c 中,尽管 all_tab_columns 确实为 Table_Name 说了 VARCHAR2(128),但它不允许超过 30 个字节的名称。

Found another article about 12c R2, which seems to be allowing this up to 128 characters. https://community.oracle.com/ideas/3338

找到另一篇关于 12c R2 的文章,它似乎允许最多 128 个字符。 https://community.oracle.com/ideas/3338

回答by Harper Shelby

In the 10g database I'm dealing with, I know table names are maxed at 30 characters. Couldn't tell you what the column name length is (but I know it's > 30).

在我处理的 10g 数据库中,我知道表名最多为 30 个字符。无法告诉您列名长度是多少(但我知道它大于 30)。

回答by Annu

The maximum name size is 30 characters because of the data dictionary which allows the storage only for 30 bytes

由于数据字典仅允许存储 30 个字节,因此最大名称大小为 30 个字符