Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle table column name with space

Tags:

sql

oracle

Is it possible to create a table with column name containing space? If so how can I create and use it?

like image 257
laksys Avatar asked Dec 10 '12 09:12

laksys


People also ask

How do I rename a column with spaces?

To select a column name with spaces, use the back tick symbol with column name. The symbol is ( ` `). Back tick is displayed in the keyboard below the tilde operator ( ~).

Can column name have space in Oracle?

It is possible, but it is not advisable. You need to enclose the column name in double quotes.

Can column name have space?

Column names can contain any valid characters (for example, spaces).

What if column name has space in SQL?

In PowerCenter a SQL query containing column names with spaces or special characters is invalid, even if the SQL is valid in the database. For example, if a Microsoft SQL query has column names with spaces, the query is valid in the Query Analyzer but invalid in the Designer.


1 Answers

It is possible, but it is not advisable. You need to enclose the column name in double quotes.

create table my_table ("MY COLUMN" number); 

But note the warning in the documentation:

Note: Oracle does not recommend using quoted identifiers for database object names. These quoted identifiers are accepted by SQL*Plus, but they may not be valid when using other tools that manage database objects.

The name will be case-sensitive, and you wil have to enclose the name in double quotes every time you reference it:

select "MY COLUMN" from my_table; 

So... don't, would be my advice...

like image 152
Alex Poole Avatar answered Sep 20 '22 23:09

Alex Poole