Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Greenville, SC
    Posts
    3

    Unanswered: How do I find the size of the field in SQL

    I am working on a JDBC - Java program to make sure that data I am going to insert into a table coming from a file is not too long for the field in the given table. Is there a way in SQL to find that out? Thanks.

    I know that the size of the field shows up if I type in "describe <tablename>" in the type column, but I want to get that by itself.

  2. #2
    Join Date
    Jan 2004
    Location
    North Haven, CT
    Posts
    110
    select table_name, column_name, data_type, data_length, data_precision, data_scale
    from dba_tab_columns
    where table_name = 'TAB1'
    and column_name = 'COL1'
    and owner = 'OWN1'

    will answer your question.

  3. #3
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208

    Re: How do I find the size of the field in SQL

    You can query the XXX_TAB_COLUMNS table where XXX is

    ALL
    DBA
    USER

    which ever you have access to

    here is an example of a query I use

    Code:
    SELECT Data_Type|| Decode(Data_Type,'DATE',null,Decode(Data_Precision,null, decode(data_type,'NUMBER',null,'('||data_length||')'),  '('||Data_Precision||','||data_Scale||')'))
    FROM all_tab_columns
    WHERE table_name = 'TABLENAME'
      AND column_name = 'COLUMNNAME'
    the decodes are used to grab the correct size information for the specific datatype

    HIH

  4. #4
    Join Date
    Feb 2004
    Location
    Greenville, SC
    Posts
    3

    Thanks

    I found out from somebody else about the getColumnDisplaySize() from the rsMetaData class which seems simpler. Thanks for all your suggestions though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •