Encrypted column in Oracle 9i

how can Encrypted column in Oracle 9i?
Oracle 9i (9.2.0.8)
Windows 2003 32bit

You can encrypt column data in Oracle 9i using the provided Oracle encryption package: DBMS_OBFUSCATION_TOOLKIT
This makes encryption and decryption an application/code feature rather than the true database feature, transparent data encryption, provided in 10g and mentioned by oradba.
10g also provides the superior DBMS_CRYPTO package where you need column level encryption of the data since TDE by itself often does not provide enough security to meet requirements for sensitive data.
HTH -- Mark D Powell --

Similar Messages

  • How to find encrypted columns in oracle 10g database

    Hi,
    How to find encrypted columns in oracle 10g database? We can see using view dba_encrypted_columns or all_encrypted_columns .
    my question is apart from this is there anyother views or tables?
    Thanks..

    user602872 wrote:
    Hi,
    How to find encrypted columns in oracle 10g database? We can see using view dba_encrypted_columns or all_encrypted_columns .
    my question is apart from this is there anyother views or tables?Hmm not which I could find,
    SQL> select * from dict where lower(table_name) like '%encrypted%';
    TABLE_NAME
    COMMENTS
    DBA_ENCRYPTED_COLUMNS
    Encryption information on columns in the database
    ALL_ENCRYPTED_COLUMNS
    Encryption information on all accessible columns
    USER_ENCRYPTED_COLUMNS
    Encryption information on columns of tables owned by the user
    SQL>HTH
    Aman....

  • How to encrypt column of some table with the single method ?

    How to encrypt column of some table with the single method ?

    How to encrypt column of some table with the single
    method ?How to encrypt column of some table with the single
    method ?
    using dbms_crypto package
    Assumption: TE is a user in oracle 10g
    we have a table need encrypt a column, this column SYSDBA can not look at, it's credit card number.
    tha table is
    SQL> desc TE.temp_sales
    Name Null? Type
    CUST_CREDIT_ID NOT NULL NUMBER
    CARD_TYPE VARCHAR2(10)
    CARD_NUMBER NUMBER
    EXPIRY_DATE DATE
    CUST_ID NUMBER
    1. grant execute on dbms_crypto to te;
    2. Create a table with a encrypted columns
    SQL> CREATE TABLE te.customer_credit_info(
    2 cust_credit_id number
    3      CONSTRAINT pk_te_cust_cred PRIMARY KEY
    4      USING INDEX TABLESPACE indx
    5      enable validate,
    6 card_type varchar2(10)
    7      constraint te_cust_cred_type_chk check ( upper(card_type) in ('DINERS','AMEX','VISA','MC') ),
    8 card_number blob,
    9 expiry_date date,
    10 cust_id number
    11      constraint fk_te_cust_credit_to_cust references te.customer(cust_id) deferrable
    12 )
    13 storage (initial 50k next 50k pctincrease 0 minextents 1 maxextents 50)
    14 tablespace userdata_Lm;
    Table created.
    SQL> CREATE SEQUENCE te.customers_cred_info_id
    2 START WITH 1
    3 INCREMENT BY 1
    4 NOCACHE
    5 NOCYCLE;
    Sequence created.
    Note: Credit card number is blob data type. It will be encrypted.
    3. Loading data encrypt the credit card number
    truncate table TE.customer_credit_info;
    DECLARE
    input_string VARCHAR2(16) := '';
    raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    key_string VARCHAR2(8) := 'AsDf!2#4';
    raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
    encrypted_raw RAW(2048);
    encrypted_string VARCHAR2(2048);
    BEGIN
    for cred_record in (select upper(CREDIT_CARD) as CREDIT_CARD,
    CREDIT_CARD_EXP_DATE,
    to_char(CREDIT_CARD_NUMBER) as CREDIT_CARD_NUMBER,
    CUST_ID
    from TE.temp_sales) loop
    dbms_output.put_line('type:' || cred_record.credit_card || 'exp_date:' || cred_record.CREDIT_CARD_EXP_DATE);
    dbms_output.put_line('number:' || cred_record.CREDIT_CARD_NUMBER);
    input_string := cred_record.CREDIT_CARD_NUMBER;
    raw_input := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    dbms_output.put_line('> Input String: ' || CONVERT(UTL_RAW.CAST_TO_VARCHAR2(raw_input),'US7ASCII','AL32UTF8'));
    encrypted_raw := dbms_crypto.Encrypt(
    src => raw_input,
    typ => DBMS_CRYPTO.DES_CBC_PKCS5,
    key => raw_key);
    encrypted_string := rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_raw)) ;
    dbms_output.put_line('> Encrypted hex value : ' || encrypted_string );
    insert into TE.customer_credit_info values
    (TE.customers_cred_info_id.nextval,
    cred_record.credit_card,
    encrypted_raw,
    cred_record.CREDIT_CARD_EXP_DATE,
    cred_record.CUST_ID);
    end loop;
    commit;
    end;
    4. Check credit card number script
    DECLARE
    input_string VARCHAR2(16) := '';
    raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    key_string VARCHAR2(8) := 'AsDf!2#4';
    raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
    encrypted_raw RAW(2048);
    encrypted_string VARCHAR2(2048);
    decrypted_raw RAW(2048);
    decrypted_string VARCHAR2(2048);
    cursor cursor_cust_cred is select CUST_CREDIT_ID, CARD_TYPE, CARD_NUMBER, EXPIRY_DATE, CUST_ID
    from TE.customer_credit_info order by CUST_CREDIT_ID;
    v_id customer_credit_info.CUST_CREDIT_ID%type;
    v_type customer_credit_info.CARD_TYPE%type;
    v_EXPIRY_DATE customer_credit_info.EXPIRY_DATE%type;
    v_CUST_ID customer_credit_info.CUST_ID%type;
    BEGIN
    dbms_output.put_line('ID Type Number Expiry_date cust_id');
    dbms_output.put_line('-----------------------------------------------------');
    open cursor_cust_cred;
    loop
         fetch cursor_cust_cred into v_id, v_type, encrypted_raw, v_expiry_date, v_cust_id;
    exit when cursor_cust_cred%notfound;
    decrypted_raw := dbms_crypto.Decrypt(
    src => encrypted_raw,
    typ => DBMS_CRYPTO.DES_CBC_PKCS5,
    key => raw_key);
    decrypted_string := CONVERT(UTL_RAW.CAST_TO_VARCHAR2(decrypted_raw),'US7ASCII','AL32UTF8');
    dbms_output.put_line(V_ID ||' ' ||
    V_TYPE ||' ' ||
    decrypted_string || ' ' ||
    v_EXPIRY_DATE || ' ' ||
    v_CUST_ID);
    end loop;
    close cursor_cust_cred;
    commit;
    end;
    /

  • Hide a column in oracle 8i tables

    I have a table in oracle which contains user name & password. But Password are not encrypted.When one give command select * from mytable it list all passwords.Is there is any way to encrypt or hide column of oracle table. IF any other way of storing password in table please tell me on urgent basis.

    e31e5144-2990-4755-8ca6-7c57ec285959 wrote:
    This weblink might help you people in encrypting the passwords in the tables.
    ORACLE-BASE - Storing Passwords in an Oracle Database
    For any queries, write to me at <redacted>
    Wish you luck.
    Kind Regards,
    Vikas
    Congratulations. You just exposed your email address on the World Wide Web.  Even as you read this, every web crawler on the planet is harvesting your address to be sold to purveyors of various, uh, anatomical enhancement products and offers to give you a piece of the action if you will only provide your bank account information to assist in laundering money out of Nigeria.   I hope you enjoy having your mail box flooded with such offers, because they are on their way.
    Also, it is considered poor nettiquete to take a technical discussion "offline" from the forum where it began, as that prevents others from benefiting from the information exchange.
    ============================================================================
    BTW, it would be really helpful if you would go to your profile and give yourself a recognizable name.  It doesn't have to be your real name, just something that looks like a real name.  Who says my name is really Ed Stevens?  But at least when people see that on a message they have a known identity.  Unlike the system generated name of 'ed0f625b-6857-4956-9b66-da280b7cf3a2', which is like going to the pub with a bag over your head.
    ============================================================================

  • Encryptind and decrypting database column in oracle 10g

    hi guys...
    i am sai sandeep,i got a doubt how to encrypt a database column in oracle 10g..?
    i am using a table " emp_uid " ,and strtucture as follows,
    create table emp_uid(user_id varchar2(20),pwd varchar2(20));
    i need to encrypt a pwd column in the emp_uid.
    how to do it..?
    thanking u  advance.....

    Ok, here's a basic example...
    SQL> create table myusers (username varchar2(30), password varchar2(40));
    Table created.
    SQL> create or replace procedure add_user(username in varchar2
      2                                      ,password in varchar2) is
      3  begin
      4    insert into myusers (username, password)
      5      values (add_user.username
      6             ,dbms_crypto.hash(utl_raw.cast_to_raw(add_user.username||'!'||add_user.password)
      7                              ,dbms_crypto.hash_sh1)
      8             );
      9    commit;
    10  end;
    11  /
    Procedure created.
    SQL> exec add_user('Fred','Fr3ddy')
    PL/SQL procedure successfully completed.
    SQL> select * from myusers
      2  /
    USERNAME                       PASSWORD
    Fred                           E5C975DB4C0A1CF65683E36421A6305F09F4EA9A
    SQL> set serverout on;
    SQL> create or replace procedure loginuser(username in varchar2
      2                                       ,password in varchar2) is
      3    v_hash     varchar2(40);
      4    v_username varchar2(30);
      5  begin
      6    v_hash := dbms_crypto.hash(utl_raw.cast_to_raw(loginuser.username||'!'||loginuser.password), dbms_crypto.hash_sh1);
      7    select username
      8    into   v_username
      9    from   myusers
    10    where  username = loginuser.username
    11    and    password = v_hash;
    12    dbms_output.put_line('User: '||v_username||' logged in.');
    13  exception
    14    when no_data_found then
    15      dbms_output.put_line('Username/Password is not valid!');
    16  end;
    17  /
    Procedure created.
    SQL> exec loginuser('Fred','Freddy');
    Username/Password is not valid!
    PL/SQL procedure successfully completed.
    SQL> exec loginuser('Fred','Fr3ddy');
    User: Fred logged in.
    PL/SQL procedure successfully completed.
    Ideally you would do the hashing of the password inside the client side application so only the Hashed value goes over the network, but the above demonstrates the principle of using hashes to store passwords.  Because it's a one way algorithm, only a brute force method can be used to try and determine the original password.  There is no way to directly un-hash the value.  To check for a valid login, we don't retrieve the password and try to unhash it to compare against what the user has supplied, we actually take what the user has supplied and hash that in the same way and then compare the hashes.
    The point of including the username or some other data in the hashing process means that if two users have the same password, they will still have different hash values, so it won't be apparent they are the same passwords.  In my example, the point of putting another character between the concatenation of username and password is in case the username and password together would give the same result e.g.
    If we had one user "Fred" with password "Fr3ddy" then just concatenating the strings would give "FredFr3ddy".
    If we had another user "FredF" and he happened to choose a password "r3ddy" then just concatenating those would also give "FredFr3ddy"
    by introducing a known breaking character they would be different e.g. "Fred!Fr3ddy" and "FredF!r3ddy" and hence give different hash values.
    That's the basics of how passwords are stored for security.
    It would take a lot of processing power and brute force methods just to determine a single password for a single user when using hashing methods of security.
    With encryption, a brute force method could be used to find the decryption key, and once found that could be used to decrypt ALL the encyrpted data, hence it is less secure, especially when some clever person will no doubt have written the key down somewhere so they don't forget it.  With hashing there's no key to write down. 

  • How to make a dmp file for a table contains encrypted column/s?

    Hi All,
    I've created a table with encrypted columns using TDE (Wallet). When I tried to make a dmp file by this command:
    exp system/password file=<path>\ex.dmp owner=ex
    the command pormpt gives this error: Feature (COLUMN ENCRYPTION) of column EMP_SSN in table EX.EMPLOYEES is not supported. the table will not be exported.
    How to solve this problem?
    I want to make a dmp file which export data of encrypted column in an encrypted format not clear format. How?
    Note:
    there is a parameter: ENCRYPTED_COLUMNS_ONLY: Encrypted columns are written to the dump file set in encrypted format

    Start by reading the manual :-
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_overview.htm#SUTIL100
    Or you can run in interactive mode :-
    [oracle@dev-oranode-221 ~]$ expdp
    Export: Release 11.2.0.1.0 - Production on Mon Nov 23 13:08:00 2009
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Username: a
    Password:
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining, Oracle Database Vault
    and Real Application Testing options
    FLASHBACK automatically enabled to preserve database integrity.
    Starting "A"."SYS_EXPORT_SCHEMA_01":  a/********
    Estimate in progress using BLOCKS method...
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 192 KB
    Processing object type SCHEMA_EXPORT/USER
    Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
    Processing object type SCHEMA_EXPORT/ROLE_GRANT
    Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
    Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
    Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
    Processing object type SCHEMA_EXPORT/TABLE/TABLE
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
    Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    Processing object type SCHEMA_EXPORT/TABLE/COMMENT
    Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    Processing object type SCHEMA_EXPORT/TABLE/POST_TABLE_ACTION
    Processing object type SCHEMA_EXPORT/MATERIALIZED_VIEW
    Processing object type SCHEMA_EXPORT/TABLE/MATERIALIZED_VIEW_LOG
    Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMA
    . . exported "A"."EMP"                                   5.421 KB       1 rows
    . . exported "A"."EMP_MV"                                5.429 KB       1 rows
    . . exported "A"."TEST"                                  5.023 KB       1 rows
    . . exported "A"."MLOG$_EMP"                                 0 KB       0 rows
    . . exported "A"."SOURCE"                                    0 KB       0 rows
    Master table "A"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
    Dump file set for A.SYS_EXPORT_SCHEMA_01 is:
      /opt/oracle/product/admin/db1122/dpdump/expdat.dmp
    Job "A"."SYS_EXPORT_SCHEMA_01" successfully completed at 13:09:23

  • Updates on encrypted column (TDE oracle10g)

    Hello All:
    Is there any way to speed up the updates on on a large encrypted column table having 40mil records .
    My experience is it is taking unusally long time and my understanding is oracle has to use decryption algorithm for each row updates.
    Any ideas appreciated.
    Thanks
    S~

    Run a trace and post the results.
    The question I would ask is whether the encryption has anything to do with it. Might a poor design cause the exact same thing without encryption? Do you know?

  • On Enabling TDE Column Encryption for 11g 11.2.0.4 , will SYS user able to decrypt, encrypted column !

    Hi ,
    we are planning to implement Transparent Data Encryption  for 11.2.0.4 11g DB .
    My Query is Whether SYS  DB user will be able to Decrypt all encrypted Columns.
    we have tested for Virtual Private Database Policy, and found out that it applies Policy for all DB Users except SYS.
    so now we have a query whether encryption will be applied for all DB users except for SYS.?
    regards
    Abdulrahman
    (P.S: attached is document how we tested for Virtual Private Database , if we can somehow disable SYS access to specific tables also our compliance requirement will be met  thanks )

    http://docs.oracle.com/cd/E11882_01/network.112/e40393/asotrans.htm#ASOAG600
    "Transparent Data Encryption(TDE) enables you to encrypt sensitive data, such as credit card numbers, stored in tables and tablespaces. Encrypted data is transparently decrypted for a database user or application that has access to data. TDE helps protect data stored on media in the event that the storage media or data file gets stolen."
    TDE encrypts data blocks.
    Users are not aware that the objects they query are encrypted - this is the reason it is called 'transparent'.

  • How to make column range based on a column in Oracle BI 11g

    Hello everyone!
    I want to know, how to make column range from a column in oracle bi 11g.
    for example!
    I have a column amounts and I want to build on this with other values of quantity, other column range 1-9,10-49,50-99,100-249, 249 o more.
    regards!
    when I try to make the range I have error.
    Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: SELECT CASE WHEN "CUBO_DEEE_TAB"."CANTIDAD" BETWEEN 1 AND 9 THEN 1 a 9 ELSE "CUBO_DEEE_TAB"."CANTIDAD" END FROM "DM_DEEE"
    Edited by: 964157 on 09-oct-2012 11:50

    You cannot add columns dynamically. But you can define a maximum number of numbers and then hide unused columns in your form useing SET_ITEM_PROPERTY(..,VISIBLE, PROPERTY_FALSE);

  • Deleting duplicate rows based on three columns in Oracle 8i

    Hi all,
    The database we use is Oracle 8i.
    The query below raises the too_many_rows exception when I launch an application. So I want to delete the duplicated rows :
    select polarisation_1, polarisation_2
    into v_pol1_tech, v_pol2_tech
    from v_cfh_lien_element
    where nom_lien = p_nom_lien
    AND num_canal_1 = p_num_canal_1
    AND freq_emise_1 = p_freq_emise_1;
    Notice that with many possible values of the parameters p_nom_lien, p_num_canal_1 and p_freq_emise_1 then the exception is raised.
    So how to delete generally the duplicated rows based on the three columns "nom_lien" , "num_canal_1" and "freq_emise_1" ?
    Thank you very much indeed.

    Check the other thread with same question deleting duplicate rows based on three columns in Oracle 8i

  • How to encrypt column of some table with the single method  on oracle7/814?

    How to encrypt column of some table with the single method on oracle7/814?

    How to encrypt column of some table with the single method on oracle7/814?

  • How to update html file in clob column in oracle

    hi,
    please help me how to update html file in clob column in oracle
    Thanks

    This is your main query as i am able to understand and you want to update your html file into terms columns based on conditions :
    SELECT     b.terms As terms
             FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
            WHERE a.enrlmnt_type_cid = 1
              AND a.chklst_item_cid = b.chklst_item_cid
              AND a.chklst_item_cid = 79
              AND a.oprtnl_flag = 'A'
              AND b.oprtnl_flag = 'A'
              AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE;So i suggest below one but you need to create a directory where you can store your html file and then you can update .. And remaining consult Experts suggestions too as your
    question is improperly posted . . .
    DECLARE
       vclob     CLOB;
       v_bfile   BFILE := BFILENAME ('YOUR_DIR', 'filename.html');
    BEGIN
       SELECT     b.terms
             INTO vclob
             FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
            WHERE a.enrlmnt_type_cid = 1
              AND a.chklst_item_cid = b.chklst_item_cid
              AND a.chklst_item_cid = 79
              AND a.oprtnl_flag = 'A'
              AND b.oprtnl_flag = 'A'
              AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE
       FOR UPDATE;
       DBMS_LOB.fileopen (v_bfile);
       DBMS_LOB.loadfromfile (vclob, v_bfile, DBMS_LOB.getlength (v_bfile));
       DBMS_LOB.fileclose (v_bfile);
    END;
    / Regards..

  • Case INSENSITIVE Columns on Oracle

    Hello Friends,
    Good Monday for everyone....
    I would like to ask you guys if there is a way to create a case INSENSITIVE Columns on Oracle. I used on Sqlserver before the COLLATE sintax, and I was able to make a columns (just that one) INSENSITIVE.
    I'm using oracle 10gr2 on Windows plataform and herte is my nls_parameters. My ideia is to search on this column without the need of performing a function UPPER and LOWER and etc...
    NLS_LANGUAGE BRAZILIAN PORTUGUESE
    NLS_TERRITORY BRAZIL
    NLS_CURRENCY Cr$
    NLS_ISO_CURRENCY BRAZIL
    NLS_NUMERIC_CHARACTERS ,.
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD/MM/RR
    NLS_DATE_LANGUAGE BRAZILIAN PORTUGUESE
    NLS_CHARACTERSET WE8MSWIN1252
    NLS_SORT WEST_EUROPEAN
    NLS_TIME_FORMAT HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMAT DD/MM/RR HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT DD/MM/RR HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY Cr$
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    tks a lot
    Keen

    APC wrote:
    No, they mean a setting which makes "APC" or "apc" match "Apc".
    There is nothing to be done on 10g, other than building a function based index on the column in question, so that any UPPER() searches are optimized.
    Well, as Kamran Agayev already noted CI is available in 10g too. It also worth mentioning FBI creates a hidden column. Also, your statement
    In 11g we have the option to set the NLS_SORT parameter so that any searches are case-insensitive (or indeed accent insensitive). Find out more.
    is incomplete. NLS_SORT affects nothing but sort:
    SQL> connect scott
    Enter password: *****
    Connected.
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    Max
    Sam
    joe
    max
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    max
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    joe
    max
    Max
    Sam
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name like 'm%'
    12  /
    NAM
    max
    SQL> select 'Max' name from dual union
      2  select 'max' name from dual
      3  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  distinct name
    10    from  t
    11  /
    NAM
    sam
    Joe
    joe
    max
    Sam
    Max
    6 rows selected.
    SQL> As you can see, NLS_SORT alone works on sort but not on "searches". We also need to set NLS_COMP, which by default is BINARY. Prior to 10g R2 (I am not 100% sure, it could be prior 10g), the only NLS_COMP choice, besides BINARY, was ANSI. However, ANSI does not work with all comparison operators (e.g. does not work for LIKE, UNION, DISTINCT):
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> alter session set nls_comp=ansi
      2  /
    Session altered.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    joe
    max
    Max
    Sam
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name like 'm%'
    12  /
    NAM
    max
    SQL> select 'Max' name from dual union
      2  select 'max' name from dual
      3  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  distinct name
    10    from  t
    11  /
    NAM
    sam
    Joe
    joe
    max
    Sam
    Max
    6 rows selected.
    SQL> Starting 10g R2 NLS_COMP can be set to LINGUISTIC, which will also work for LIKE and UNION but not for DISTINCT:
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> alter session set nls_comp=linguistic
      2  /
    Session altered.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    joe
    max
    Max
    Sam
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name like 'm%'
    12  /
    NAM
    Max
    max
    SQL> select 'Max' name from dual union
      2  select 'max' name from dual
      3  /
    NAM
    Max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  distinct name
    10    from  t
    11  /
    NAM
    sam
    Joe
    joe
    max
    Sam
    Max
    6 rows selected.
    SQL> However even LINGUISTIC does not work with:
    • CLOB or NCLOB data types
    • Object data types
    • Table partitions
    • Index-organized tables
    SY.

  • Streaming data to LONG columns in Oracle 7.3.2.3.0

    I am trying to stream data to a LONG column. I'm using Oracle
    Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    SP5.
    I include sample tables/programs at the end, but here's the
    summary of what's happening:
    I'm creating a byte array of length 2500. If I use
    setAsciiStream I get the following exception when I execute the
    prepared statement:
    java.sql.SQLException: Data size bigger than max size for this
    type
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java)
    at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java)
    at oracle.jdbc.driver.OraclePreparedStatement.setItem
    (OraclePreparedStat
    ement.java)
    at
    oracle.jdbc.driver.OraclePreparedStatement.setAsciiStream
    (OraclePrepa
    redStatement.java)
    at TestOracle.main(TestOracle.java:26)
    If I use setBinaryStream I get this exception:
    java.sql.SQLException: ORA-01461: can bind a LONG value only for
    insert into a LONG column
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7
    (TTC7Protocol.java)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch
    (TTC7Protocol.java)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther
    (OracleStatement.jav
    a)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch
    (OracleStatement
    .java)
    at oracle.jdbc.driver.OracleStatement.doExecute
    (OracleStatement.java)
    at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout
    (OracleStateme
    nt.java)
    at
    oracle.jdbc.driver.OraclePreparedStatement.executeUpdate
    (OraclePrepar
    edStatement.java)
    at oracle.jdbc.driver.OraclePreparedStatement.execute
    (OraclePreparedStat
    ement.java)
    at TestOracle.main(TestOracle.java:27)
    My Oracle7 manual states that LONG columns can store 2GB of text.
    I tried the above with LONG RAW columns and it worked fine.
    Can anyone explain why I get this error? I've tried it with
    different sizes and when the data is <2000 bytes it works fine
    for LONG columns.
    My table is simple:
    create table TestLongs (key INTEGER PRIMARY KEY, data LONG);
    My Java code is also very simple:
    public class TestOracle
    public static void main(String[] args)
    Connection con = null;
    PreparedStatement pstmt = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@itchy:1526:test",
    "System", "<OMITTED>");
    byte[] data = new byte[2500];
    for (int i=0; i< 2500; i++)
    data[i] = 53;
    String sql = "INSERT INTO TestLongs (key, data)
    VALUES(1, ?)";
    pstmt = con.prepareStatement(sql);
    ByteArrayInputStream bis = new ByteArrayInputStream
    (data);
    pstmt.setAsciiStream(1, bis, data.length);
    pstmt.execute();
    catch (SQLException e)
    System.err.println("An error occurred with the
    database: " + e);
    e.printStackTrace();
    catch (Exception e)
    System.err.println("Oracle JDBC driver not found." +
    e);
    e.printStackTrace();
    finally
    try
    if (pstmt != null)
    pstmt.close();
    if (con != null)
    con.close();
    catch (SQLException e)
    System.err.println("Unable to close
    statement/connection.");
    null

    Robert Greig (guest) wrote:
    : I am trying to stream data to a LONG column. I'm using Oracle
    : Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    : SP5.
    I tried it with the old 7.3.x JDBC driver and it works fine. I
    also noticed after further testing that it sometimes worked
    with the 8.0.4 driver. Looks like a bug in the 8.0.4 driver or
    some wacky incompatibility.
    null

  • How to create an automatically increment column in Oracle DB Table?

    Hi To All
    Here I am trying to create a table in Oracle that creates an automatically increment column in Oracle DB Table. i searched almost all Forums.(Even in Oracle). They are saying that, that logic u must implement in Java Code.(*Takes Maximum no from table, add +1 to it, and store it back again)*. apart from this, while creating an table in Oracle, is there any facility like MySQL Database? please help me. Thanks in advance.

    Hi BalusC
    Thanks for Your Response and clue. with that, i succeeded in my application. Thank you very much. here i am giving you the details which i did.
    1. I Created a table named orders in Oracle like this.
       CREATE TABLE ORDERS (ORDER_ID NUMBER, CUSTOMER_ID NUMBER, ISBN NUMBER,
                                   DESCRIPTION NCHAR(5));
                       2. I created one sequence in Oracle like    CREATE SEQUENCE SEQ01 INCREMENT BY 1 START WITH 1000     3. Then i have written jdbc program like this
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    public class SequenceTest {
         public static void main(String[] args)throws Exception{
              try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
              String cols[] = {"ORDER_ID", "DESCRIPTION"};
              PreparedStatement pstmt = con.prepareStatement("INSERT INTO ORDERS (ORDER_ID, CUSTOMER_ID, ISBN,DESCRIPTION) VALUES            (SEQ01.NEXTVAL, 104, 966431505,?)", cols);
              pstmt.setString(1,"Desc3");          
              pstmt.executeUpdate();
              ResultSet rs=pstmt.getGeneratedKeys();     
                    System.out.println("---- One Row Inserted ----");
              } catch (Exception e) {
                   System.out.println("---- Failed Due To "+e);               
       4. When i ran above program 5 times, i got the following Data into my Oracle Table (select * from orders)
      ORDER_ID CUSTOMER_ID       ISBN DESCR
          1000         101  966431502 Desc0
          1001         102  966431503 Desc1
          1002         103  966431504 Desc2
          1003         104  966431505 Desc3
          1004         104  966431505 Desc3
          1005         105  966431506 Desc4
    6 rows selected.
      But i dont know how to do this type of program with out using prepared statements. i tried, and i got exception *"Missing Expression"* .
    Once again Thank You very much for your clue.

Maybe you are looking for

  • Unable to print multiple copies of a PDF

    I am running Adobe Reader X version 10.1.3 on a MacBook Pro with Mac OSX 10.7. For some reason I can only print one copy of a PDF at a time, even if I set the number of copies in the print dialogue box and the Printer dialogue box. Help!  It's very f

  • Open Directory Users can't add printers

    Hi all, I've set up my teachers on OD on OS X Server 10.5 but now when they log in, they cannot add any printers. I've tried many different things to get the lock on the Print & Fax System Pref to be unlocked by default but nothing I've tried works.

  • HT1212 I dropped my phone, and can no longer see the screen.

    I need to sync my phone one last time to get the info off, but the screen is blank, and I can't unlock it.  Itunes tells me I must unlock it to sync it.  Any suggestions?

  • Again another confused complaining thread by mysel...

    Hey again and again and again XD Incase a mod reads this can you check and see how far along in the queue my email is as its been about 5 days i think, anyways. So i was connected up to about 3 days and 12 hours averaging 5.8mb and then my hub reset.

  • Manual for CS4 Extended?

    I found the 705-page Help Manual for Photoshop CS4 but I can't find any Help coverage for the Extended portion dealing with 3D graphics.  Is there a separate manual online or even available from Adobe?