今天做insert的练习做到从外面的表导入数据,突然想到我怎么才能获取原表字段的数据类型以及长度,嘿嘿我是个新手么总被这样的小问题难住,然后搜索了一下最后解决了这个问题。
 
SELECT data_type,data_length FROM user_columns where table_name='emp';
 
其中emp为所要查的表名字
USER_TAB_COLUMNS
Columns of user's tables, views and clusters
 Columns 
    ___________________________ ___________________________

    TABLE_NAME TABLE_NAME
       Table,view or cluster name
    COLUMN_NAME COLUMN_NAME
       Column name
    DATA_TYPE DATA_TYPE
       Datatype of the column
    DATA_TYPE_MOD DATA_TYPE_MOD
       Datatype modifier of the column
    DATA_TYPE_OWNER DATA_TYPE_OWNER
       Owner of the datatype of the column
    DATA_LENGTH DATA_LENGTH 
       Length of the column in bytes 
    DATA_PRECISION DATA_PRECISION 
       Length: decimal digits (NUMBER) or binary digits (FLOAT)
    DATA_SCALE DATA_SCALE 
       Digits to right of decimal point in a number 
    NULLABLE 
       Does column allow NULL values?
    COLUMN_ID COLUMN_ID 
       Sequence number of the column as created
    DEFAULT_LENGTH DEFAULT_LENGTH 
       Length of default value for the column 
    DATA_DEFAULT DATA_DEFAULT 
       Default value for the column 
    NUM_DISTINCT NUM_DISTINCT 
       The number of distinct values in the column 
    LOW_VALUE LOW_VALUE 
       The low value in the column 
    HIGH_VALUE HIGH_VALUE 
       The high value in the column 
    DENSITY 
       The density of the column 
    NUM_NULLS NUM_NULLS 
       The number of nulls in the column 
    NUM_BUCKETS NUM_BUCKETS 
       The number of buckets in histogram for the column 
    LAST_ANALYZED LAST_ANALYZED 
       The date of the most recent time this column was analyzed 
    SAMPLE_SIZE SAMPLE_SIZE 
       The sample size used in analyzing this column 
    CHARACTER_SET_NAME CHARACTER_SET_NAME 
       Character set name 
    CHAR_COL_DECL_LENGTH CHAR_COL_DECL_LENGTH 
       Declaration length of character type column 
    GLOBAL_STATS GLOBAL_STATS 
       Are the statistics calculated without merging underlying partitions?
    USER_STATS USER_STATS 
       Were the statistics entered directly by the user? 
    AVG_COL_LEN AVG_COL_LEN 
       The average length of the column in bytes
    CHAR_LENGTH CHAR_LENGTH 
       The maximum length of the column in characters 
    CHAR_USED CHAR_USED 
       C is maximum length given in characters,B if in bytes  
    V80_FMT_IMAGE V80_FMT_IMAGE 
       Is column data in 8.0 p_w_picpath format? 
    DATA_UPGRADED DATA_UPGRADED 
       Has column data been upgraded to the latest type version format?
 
听说还有一种可以从数据字典中查到同样的信息,希望看到这篇文章的大大不吝赐教,谢谢~