Sumit Nagpal
Sumit Nagpal

Reputation: 43

How to rename, or even access a column with spaces in its name?

A table with one of the column names as 'Person Rank' is uploaded on Azure, and then accessed via Databricks Notebook.

So writing sql statements using this column is giving errors, even renaming it is a problem.

All the following commands give errors:

SELECT Person Rank FROM Table1
SELECT 'Person Rank' FROM Table1
SELECT "Person Rank" FROM Table1

How to access this column in sql command?

Upvotes: 2

Views: 2071

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269753

I think Databricks uses the backtick to escape identifiers, so try:

SELECT `Person Rank` FROM Table1

Upvotes: 1

Related Questions