OraQA

Oracle Question and Answer

  • Do you have a solution to a problem? Do you have an unanswered question? Login and share it with the Oracle community. More...

Oracle News


Entries RSS feed

Comments RSS feed

How to avoid special characters in column names?

September 21st, 2006 By madan30

I am taking input from some CSV file to create a table and its data. The column names are also created from the CSV file. However, The column names have some characters like %,-,$,() etc … resulting in an error during table creation.

How can I filter out these special characters from the column names?

One Response to “How to avoid special characters in column names?”

  1. Eddie Awad Says:

    You do not need to filter out special characters as long as you wrap your column names with qutation marks:

    SQL> CREATE TABLE t
      2  ("this%is,so-,cool$,man()" VARCHAR2(10),
      3  "This@#is^~even+&cooler" NUMBER)
      4  /
    
    Table created.
    
    SQL> INSERT INTO t VALUES ('A', 1)
      2  /
    
    1 row created.
    
    SQL> INSERT INTO t VALUES ('B', 2)
      2  /
    
    1 row created.
    
    SQL> SELECT * FROM t
      2  /
    
    this%is,so This@#is^~even+&cooler
    ---------- ----------------------
    A                               1
    B                               2
    

    If you still want to remove these special characters, two SQL functions may come in handy: TRANSLATE and REPLACE.

Leave a Reply

You must be logged in to post a comment.

RSS feed for comments on this question