CHAR_COL_DECL_LENGTH in ALL_TAB_COLUMNS

Hello,
Recently I've upgraded characterset of database to UTF8 and set NLS_LENGTH_SEMANTICS to CHAR.
I'm creating a sample table
create table sample4
(name1 char(1000),
name2 char(2000),
name3 varchar2(3000),
name4 varchar2(4000)
But the output in this query rounds the name3 column value to 4000 char even if it is less then 4000 chars. I'm trying to understand more in this multibyte conversion detail. Pleaes post any metalink note available in this regard.
thanks,
Kam

Not sure what CHAR_COL_DECL_LENGTH exactly means for multibyte character sets but note that UTF8 characters have no fixed length and this could explain the rounding you have noted:
>
The UTF8 Oracle Database character set encodes characters in one, two, or three bytes. It is for ASCII-based platforms. The UTF8 character set supports Unicode 5.0 and it is compliant to the CESU-8 standard. Although specific supplementary characters were not assigned code points in Unicode until version 3.1, the code point range was allocated for supplementary characters in Unicode 3.0. Supplementary characters are treated as two separate, user-defined characters that occupy 6 bytes.
>
Do CHAR_COL_DECL_LENGTH has the same value as DATA_LENGTH ?
What is your 4 digits Oracle version ?
Edited by: P. Forstmann on 5 juil. 2011 17:51

Similar Messages

  • NEED HELP IN USING ALL_TAB_COLUMNS FOR RETRIEVING DATA???

    A table say T1 contains column like Emp_id,Code.
    and there are several Code like C1,C2,C3.
    Another table say T2 contains column like
    Emp_id,C1,C2,C3.Here the value of the code field of the
    T1 table is now column of the T2 table.And the amount of
    each code of T1 table is equal to column value of T2
    table.
    Now I want to retrieve data from T2 table like
    C1 200
    C2 300
    C3 140
    I cannot retrieve data like this using all_tab_columns.
    I can only getting the column_name but cannot its value.
    PLEASE HELP ME...
    Edited by: user630863 on Apr 8, 2009 11:37 AM

    emp_id | code
    001 | C1
    001 | C2
    005 | C3
    005 | C1
    002 | C2
    002 | C3
    Table T1
    emp_id | C1 | C2 | C3
    001 | 10 | 15 |
    002 | | 7 | 12
    005 | 45 | | 94
    Table T2
    I have written a query
    select column_name from all_tab_columns a,T1 b
    where a.column_name=b.code
    and table_name='T2'
    OUTPUT:
    C1
    C2
    C3
    But I Need data for each employee like
    001 C1 10
    001 C2 15
    002 C2 7
    002 C3 12
    005 C1 45
    005 C3 94
    Edited by: user630863 on Apr 8, 2009 1:28 PM

  • Is it possible to view "all_tab_columns" entries in "user_tab_columns"?

    Good morning,
    I have here a SQL query that searches for entries in "user_tab_columns".
    Unfortunately the mentioned entries are not present there (but they are present in "all_tab_columns", but I also think that the query is correct.
    Therefore I wonder:
    is it possible to modify the database (using granting permissions, DB links or other) so that the mentioned entries in "all_tab_columns" also get visible in "user_tab_columns"?
    Thanks
    Dominique

    Hi, Dominique,
    You can create a private synonym called user_tab_columns that will stand for all_tab_columns
    CREATE SYNONYM user_tab_columns FOR sys.all_tab_columns;That means, whenever you say user_tab_columns, Oracle will understand you really want sys.all_tab_columns.
    If you need to reference the real user_tab_columns, then you can create another synonym like this:
    CREATE SYNONYM real_user_tab_columns FOR sys.user_tab_columns;This will affect only the user who creates the synonym. If you log in as DOMINIQUE, then anyone logged in as DOMINIQUE will be affected, but people who log in as SCOTT (for example) will not be. (Of course, SCOTT can also create a priovate synonym, which would only affect users logged in as SCOTT).
    Remember that sys.all_tab_columns and sys.user_table_columns are different. Something that was designed to work in user_tab_columns will not necessarily work in all_tab_columns. For example, a query that finds how many columns are in the emp table. If dominique.emp has 5 columns, then when dominique runs
    SELECT  COUNT (*)   AS total_columns
    FROM    user_tab_columns
    WHERE   table_name  = 'EMP';the answer will be 5, but if dominque has privileges on the scott.emp table, which has 8 columns, then the results of:
    SELECT  COUNT (*)   AS total_columns
    FROM    all_tab_columns
    WHERE   table_name  = 'EMP';will be 5 + 8 = 13, which is not the correct number of columns in either emp table.
    Edited by: Frank Kulash on Aug 11, 2011 12:46 PM
    Corrected typos

  • Accessing ALL_TAB_COLUMNS from a Procedure

    Hi,
    I want a help in Accessing ALL_TAB_COLUMNS from a procedure.
    I am an getting Error as Insufficient Privileges while Executing the Procedure.
    Any help will be Benefitial
    Thanks and Regards

    You should not really be using SYS.
    Is this a general issue with accessing "ALL_" views (i.e. information about other schemas than your own) within procedures? If so perhaps the account needs SELECT ANY DICTIONARY system privilege. although as with any system privilege you should consider the security implications.
    If it's specifically ALL_TAB_COLUMNS and not the rest of the dictionary views, then a grant on that view to the owner of the package will do it.

  • Duplicates in all_tab_columns

    I have found duplicates in the all_tab_columns data dictionary view, where both rows have the same owner, table_name, and column_name, but have different column_id and one row shows the column as nullable and the other row shows the column as not nullable. However, only one such entry exists in the user_tab_columns data dictionary view. Is there any rational explanation for this or is corruption the only possibility?
    The database in question is used for development and testing and is periodically modified to match the production database. I know that one of the DBA's has been using TOAD to do this, but I don't know what the exact process has been and he is on vacation at the moment.
    This problem exists in multiple tables and multiple columns. In each case, the columns in question were formerly part of a primary key, but that has been changed so that the primary key now uses other columns.
    Below is just one small example that shows the duplicates in all_tab_columns, but not in user_tab_columns.
    Barbara Boehmer
    SQL*Plus: Release 8.0.6.0.0 - Production on Wed Mar 12 23:57:07 2003
    (c) Copyright 1999 Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
    With the Partitioning option
    JServer Release 8.1.7.0.0 - Production
    SQL> SELECT      table_name, column_name, column_id, nullable
      2  FROM        all_tab_columns
      3  WHERE       user = USER
      4  AND         table_name = 'ADDRESSES'
      5  AND         column_name = 'ADDR__EVNT_SEQ'
      6  /
    TABLE_NAME                     COLUMN_NAME                    COLUMN_ID N
    ADDRESSES                      ADDR__EVNT_SEQ                        39 Y
    ADDRESSES                      ADDR__EVNT_SEQ                         4 N
    SQL> SELECT      table_name, column_name, column_id, nullable
      2  FROM        user_tab_columns
      3  WHERE       user = USER
      4  AND         table_name = 'ADDRESSES'
      5  AND         column_name = 'ADDR__EVNT_SEQ'
      6  /
    TABLE_NAME                     COLUMN_NAME                    COLUMN_ID N
    ADDRESSES                      ADDR__EVNT_SEQ                        39 Y

    Barbara, in your all_tab_columns query, you have put a condition 'user = USER'.
    I think you meant to say 'owner = USER'. If you add owner to the result set, the two rows should have different owners.
    barryt> create table addresses (addr__evnt_seq int not null);
    Table created.
    barryt> grant select on addresses to rms;
    Grant succeeded.
    barryt> @connect
    rms> create table addresses (dummy int not null, addr__evnt_seq int);
    Table created.
    rms> select table_name, column_name, column_id, nullable   
    2    from all_tab_columns   
    3   where user = USER  -- applies no filter 
    4     and table_name = 'ADDRESSES'   
    5     and column_name = 'ADDR__EVNT_SEQ';
    TABLE_NAME                     COLUMN_NAME                    COLUMN_ID N
    ADDRESSES                      ADDR__EVNT_SEQ                         2 Y
    ADDRESSES                      ADDR__EVNT_SEQ                         1 N
    2 rows selected.
    rms> select owner, table_name, column_name, column_id, nullable   
    2    from all_tab_columns   
    3   where table_name = 'ADDRESSES'   
    4     and column_name = 'ADDR__EVNT_SEQ';
    OWNER                          TABLE_NAME
    COLUMN_NAME                    COLUMN_ID N
    RMS                            ADDRESSES
    ADDR__EVNT_SEQ                         2 Y
    BARRYT                         ADDRESSES
    ADDR__EVNT_SEQ                         1 N
    2 rows selected.
    rms> select table_name, column_name, column_id, nullable   
    2    from all_tab_columns 
    3   where owner = USER 
    4     and table_name = 'ADDRESSES'   
    5     and column_name = 'ADDR__EVNT_SEQ';
    TABLE_NAME                     COLUMN_NAME                    COLUMN_ID N
    ADDRESSES                      ADDR__EVNT_SEQ                         2 Y
    1 row selected.
    rms> select table_name, column_name, column_id, nullable   
    2    from user_tab_columns 
    3   where table_name = 'ADDRESSES'   
    4     and column_name = 'ADDR__EVNT_SEQ';
    TABLE_NAME                     COLUMN_NAME                    COLUMN_ID N
    ADDRESSES                      ADDR__EVNT_SEQ                         2 Y

  • DATA_LENGTH in all_tab_columns in BYTE/CHAR???

    Hi
    in the Oracle 11gR2 or 10gR2 documentation you find the following description of ALL_TAB_COLUMNS.DATA_LENGTH.
    DATA_LENGTH      NUMBER      NOT NULL      Length of the column (*in bytes*)But what about VARCHAR2 fields which have been created with
    NLS_LENGTH_SEMANTICS='CHAR'My observation is, that in 10g ALL_TAB_COLUMNS.DATA_LENGTH shows the length in what ever mode, you have created the table. So, if I have created a VARCHAR2 field as VARCHAR2(4 CHAR), then ALL_TAB_COLUMNS.DATA_LENGTH will show 4. In 11g however the field shows really the length in bytes. So I observed data_length=16 for a field which had been defined as VARCHAR2(4 CHAR) on a 11gR2 database with NLS_CHARACTERSET= "AL32UTF8".
    Is there any contrary observation or experience?

    Thanks guys,
    you are right my 10g DB used to have
    NLS_CHARACTERSET               WE8ISO8859P1which makes everything very clear.
    Very helpful is the field CHAR_LENGTH and CHAR_USED which indeed contain the information I need.
    Thanks.

  • DATA_DEFAULT In ALL_TAB_COLUMNS...

    Hi all,
    I'm working in an existing codebase (VB.Net) that is using an Oracle Database. One of the things the application is doing is getting a copy of the default value for the different columns. It looks something like this:
    If Not String.IsNullOrEmpty(myRow(0).Item("Data_Default").ToString) Then
    myCol.DefaultValue=myRow(0).Item("Data_Default").ToString
    End If
    That Data_Default value is being populated from the ALL_TAB_COLUMNS table; using a DataAdapter.Fill statement.
    Currently, the system is using a stored procedure, and inside that stored proc we're converting the DATA_DEFAULT column (which is a LONG) into a VARCHAR2. If that conversion doesn't happen, and we simply include the DATA_DEFAULT column in our SELECT statement, the datatable that the adapter fills will have a value of 'NULL' for DATA_DEFAULT in each and every row.
    This conversion takes a long time. Doing the query without the conversion in PL/SQL takes .2 seconds. Doing the conversion takes *40* seconds. That's 200x as long!
    I'm certain that something is being done incorrectly here. Can someone let me know where I've gone wrong? I just feel like there has to be a better way to do this; but I'm not sure what.

    First - I want to apologize for asking such a silly question.
    Second - I'll respond in the hopes that someone else with my question will find this on google and save himself the embarassment.
    By default, when you perform a SELECT and pull back a LONG, you get the first 0 bytes of it. You get nothing. That's why, when I filled my datatable it was always null.
    What you want to do (instead of all this on the fly conversion crap I was doing) is simply tell Oracle to give you more than 0 bytes for each long.
    cdLookup = New Oracle.DataAccess.Client.OracleCommand
    cdLookup.InitialLONGFetchSize = 500
    Nice and simple; problem solved. Sorry again!

  • Raw Values in all_tab_columns (8i)

    I want to retreive Low_value and High_value from all_tab_columns. These fields use the raw datatype. How do I convert them to a decimal number. I am using Oracle 8i.
    Thanks,
    Les Smith

    Hi,
    Thanks everyone who replied to my question. I found the stats table created by the DBMS_STATS package would store the low_value and high_value in a decimal format. I used the DBMS_STATS.EXPORT_TABLE_STATS procedure to take the system statistics and place them in a user stats table.
    Here is the approach I took:
    DECLARE
    BEGIN
    --CREATE A USER TABLE TO HOLD THE STATISTICS
    DBMS_STATS.CREATE_STAT_TABLE (
    'ADW',
    'STATS_TAB');
    --RUN STATS TO POPULATE SYSTEM STAT TABLE
    SYS.DBMS_STATS.GATHER_TABLE_STATS (
    'ADW',
    'MSF');
    DBMS_STATS.EXPORT_TABLE_STATS (
    ownname => 'ADW',
    tabname => 'MSF',
    stattab => 'STATS_TAB');
    END;
    SELECT
    C4 AS COLUMN_NAME,
    N1 AS NUM_DISTINCT,
    N5 AS NUM_NULLS,
    N6 AS LOW_VALUE,
    N7 AS HIGH_VALUE,
    N8 AS AVG_COL_LENGTH
    FROM STATS_TAB
    WHERE TYPE ='C'

  • How to concatenage text to data_default col of all_tab_columns.

    Hi,
    i want to concatinate text to a columen like this but it is show error ,so i thought to convert it but could not get correct code.
    select 'dff' || data_default || 'df' from all_tab_columns
    yours sincerley

    Hi,
    data default is a LONG datatype. You cannot convert it straight away to VARCHAR2.
    I would suggest you to have a look at this: Ask Tom: Long to Varchar2 conversion.
    In the same page Tom has put an example about getting default value for columns:
    ops$tkyte%ORA11GR2> create or replace function get_col_default
      2  (
      3  p_owner in all_tab_cols.owner%type,
      4  p_table_name in all_tab_cols.table_name%type,
      5  p_column_name in all_tab_cols.column_name%type
      6  )
      7  return varchar2
      8  as
      9          l_data_default LONG;
    10  begin
    11          select data_default into l_data_default
    12            from all_tab_cols
    13           where owner = p_owner
    14             and table_name = p_table_name
    15             and column_name = p_column_name;
    16 
    17          return substr( l_data_default, 1, 4000 );
    18  end;
    19  /
    Function created.
    ops$tkyte%ORA11GR2>
    ops$tkyte%ORA11GR2> column d format a20
    ops$tkyte%ORA11GR2> select owner, table_name, column_name, get_col_default( owner, table_name,
    column_name ) d
      2    from all_tab_cols
      3   where get_col_default( owner, table_name, column_name ) is not null
      4     and rownum <= 5
      5  /
    OWNER                          TABLE_NAME                     COLUMN_NAME                    D
    SYS                            HS$_PARALLEL_METADATA          PARALLEL                       'Y'
    SYS                            HS$_PARALLEL_METADATA          PARALLEL_DEGREE                4
    SYS                            HS$_PARALLEL_METADATA          RANGE_PARTITIONED              'N'
    SYS                            HS$_PARALLEL_METADATA          SAMPLED                        'N'
    SYS                            HS$_PARALLEL_METADATA          HISTOGRAM                      'N'Regards.
    Al

  • Difference between user_tab_columns and all_tab_columns

    Hi,
    Can anybody please let me know what are the differeneces between user_tab_columns and all_tab_columns.
    Thank you.

    Hi,
    In addition to sybrand_b information
    ALL_TAB_COLUMNS is a view that has an entry for every column of every table of every users schema, describes the columns of the tables, views, and clusters accessible to the current user
    USER_TAB_COLUMNS is a view that has an entry for every column of every table in a certain user's schema. When you use desc on a table to show the columns of that table the order of the columns shown is determined by the position that you can see when you look at the column_id in all_tab_columns and/or user_tab_columns. The DBA may change the order of these columns. It is very important not to assume that the columns are in a certain order and will stay that way, describes the columns of the tables, views, and clusters owned by the current user. Its columns (except for OWNER) are the same as those in "ALL_TAB_COLUMNS
    :)

  • Want to construct insert statement from all_tab_columns

    I am using Oracle 10GR2 and a new user for plsql
    I want to write a plsql block or SQL in order to insert some dummy data.
    I want to use the column list from all_tab_columns and want to construct insert statement
    EX: I am trying to construct SQL as below
    for i in (select column_name from all_tab_columns where table_name='EMP')
    loop
    v_sql := insert into emptest valuesi.column_name
    could you please let me know any pointer for the same ..?
    can I use any other technique for the same .. like collection, nested table etc

    Am not clear for this requirement, if possible could you please elaborate.
    Also specify the requirement, inputs and expected outputs with your query in code format...
    This will help..

  • AFTER ALTER ON SCHEMA TRIGGER + all_tab_columns

    Hi everybody,
    I'm trying to get the column name of any column added to the table "TEST", So I create a trigger to ensure that job.
    My problem is that the view "all_tab_columns" doesn't contain the column "column_test " yet when the trigger audit_ddl_trg is executed.
    Please Help me to resolve this problem
    CREATE TABLE TEST(id varchar2(10));
    -- add a column to the Table "TEST"
    alter table TEST add column_test varchar2(10);
    -- column_test not detected !!?
    CREATE OR REPLACE TRIGGER audit_ddl_trg AFTER ALTER ON SCHEMA
    DECLARE
    col_name varchar2(30);
    BEGIN
    IF (ORA_DICT_OBJ_TYPE = 'TABLE' AND ora_dict_obj_owner = 'OP' AND ORA_DICT_OBJ_NAME = 'TEST') THEN
    FOR col_name IN (SELECT column_name FROM all_tab_columns WHERE owner = 'OP') LOOP
    DBMS_OUTPUT.PUT_LINE('Column : ' || col_name);
    END LOOP;
    END IF;
    END;
    Thanks In Advance ;)
    Edited by: 909366 on Jan 26, 2012 1:22 AM
    Edited by: 909366 on Jan 26, 2012 1:57 AM

    True, you can declare PROC_REPLACE_TRIGGER as an autonomous transaction. That would allow you to commit. But then your autonomous transaction won't be able to see any of the changes being made in the triggering transaction, including the new column.
    As has been said before, you really only have one option. Your schema trigger needs to use DBMS_JOB to schedule a job. That job would call PROC_REPLACE_TRIGGER some time shortly after the triggering DDL transaction commits. You would not want to declare PROC_REPLACE_TRIGGER as an autonomous transaction in that approach.
    I still have reservations about the architecture that would require something like this. If you're doing DDL, presumably it's part of a build. The call to PROC_REPLACE_TRIGGER should be part of the build script (assuming it really makes sense to recreate triggers dynamically), not something that is called by a trigger.
    Justin

  • USER_TAB_COLUMNS and ALL_TAB_COLUMNS

    Dear Experts,
    I'm logged on a schema called Product with a user having the following rights:
    - Create Session
    - Select any sequence
    - Select any table
    If I perform a select on USER_TAB_COLUMNS I don't get any row returned but I do get results if I perform a select on ALL_TAB_COLUMNS. I can these two tables are SYS and select is granted to PUBLIC on both.
    So I don't undestand why I don't get a result from USER_TAB_COLUMNS. Any clue ?
    Thanks for any help.
    BR,
    Jerome.

    USER_TAB_COLUMNS will only show columns in tables owned by the current user - PRODUCT. Tables owned by SYS will not be visible to PRODUCT in the USER view, only in the ALL view.

  • Dba_tab_columns and all_tab_columns

    HI
    AIX 5.3
    oracle 10.2.0.3
    which view should be accessible to developers dba_tab_columns or all_tab_columns? and why?
    also dba_* and all_*
    Thanks,
    vishal

    ALL_* - displays all the information accessible to the current user, including information from the current user's schema as well as information from objects in other schemas, if the current user has access to those objects by way of grants of privileges or roles.
    DBA_ view displays all relevant information in the entire database. DBA_ views are intended only for administrators. They can be accessed only by users with the SELECT_ANY_TABLE privilege. (This privilege is assigned to the DBA role when the system is initially installed.)
    USER_ view displays all the information from the schema of the current user. No special privileges are required to query these views
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1001.htm#i1572007
    http://download-uk.oracle.com/docs/cd/A97630_01/server.920/a96536/ch2.htm
    HTH
    -Anantha

  • Joining a table with all_tab_columns

    How is it possible to join a table with the tab_columns?
    The query im trying to establish is that in my table they are 12 columns with months names. So under an input variable im trying to return the required values with the selected months. The only way i could think of to get the months to connect with the tab_columns table.
    Any suggestion is really appreciated
    SELECT bust,
    Sum(jan) JAN,
    Sum(feb) FEB,
    Sum(mar) MAR,
    Sum(apr) APR,
    Sum(may) MAY,
    Sum(jun) JUN,
    Sum(jul) JUL,
    Sum(aug) AUG,
    Sum(sep) SEP,
    Sum(oct) OCT,
    Sum(nov) NOV,
    Sum(DEC) DECC
    FROM budget a,all_tab_columns b
    WHERE vsl_code = 4602
    AND code = 1
    AND year=2013
    AND account_code='30'
    AND b.table_name='BUDGET'
    AND b.column_name IN
                         (SELECT column_name
                          FROM (SELECT Column_name, ROWNUM r
                                        FROM all_tab_columns b
                                        WHERE table_name = 'BUDGET'
                                        AND Column_id BETWEEN 3 AND 14
                                        ORDER BY column_id)
                          WHERE r BETWEEN 2 AND 3 ) --Returns February,March
    group by bust;

    Sorry, I don't understand what you're trying to do or why you think you need to join to all_tab_columns. Perhaps you could post the definition of the budget table, some sample data, and the results you're hoping to see.
    Without that, I don't see why you can't just do this:
    SELECT bust,   
    Sum(jan) JAN,   
    Sum(feb) FEB,   
    Sum(mar) MAR,   
    Sum(apr) APR,  
    Sum(may) MAY,  
    Sum(jun) JUN,   
    Sum(jul) JUL,   
    Sum(aug) AUG,   
    Sum(sep) SEP,   
    Sum(oct) OCT,  
    Sum(nov) NOV,   
    Sum(DEC) DECC  
    FROM budget a
    WHERE vsl_code = 4602  
    AND code = 1  
    AND year=2013  
    AND account_code='30' 
    group by bust;

Maybe you are looking for

  • REALLY need help on this one... befw11s4 w/ Xbox 360

    My system 2 PCs hard wired. 2 Printers wireless.  Running XP.  Also have Directv DVR and Xox 360.  Everything used to function correctly. Now DVR and XBox wont connect to BEFWS11 V2.  I have reset everything and started from scratch.  I have also dis

  • Error with php_oci8.dll

    Hi everyone. I have the following error with the php_oci8.dll (apache error log): PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files (x86)\\PHP\\ext\\php_oci8.dll' - %1 is not a valid Win32 application.\r\n in Unknown on line

  • PMON and ORA-01102: cannot mount database in EXCLUSIVE mode error

    hello all I have been asked to look into a problem server with the following details OS: sunOS 5.8 Oracle: 10.2.0.1 sys user password is not available ! backgrround processes for the instance(sid=test) are running only schema credentials available an

  • Poor quality noise reduction for Canon G10

    I recently bought a Canon G10, and I am disappointed at the quality of RAW conversions done by ACR/LR at anything approaching a high ISO. The out-of-camera JPEGs show much superior noise reduction to what I can get from RAW files, no matter how I twe

  • Not starting from the beginning of podcasts?

    Hello, I am having an issue with my iphone 4, running IOS4.1. About half of the time, when I start a podcast, it starts in the middle. Very odd. Anyone know of fixes or others having this problem? Thanks! Jme