Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create column name with space?

Tags:

sql

mysql

Can anybody tell me how to create columns with space like "FULL NAMES"? I've tried like the following but it doesn't work.

CREATE TABLE info
(
Full Names varchar(20),
Physical Address varchar(20),
Moviesrented varchar(100),
Salutation varchar(20),
Category varchar(20),
PRIMARY KEY (address)
)
like image 380
Noah_bean Avatar asked Jul 29 '14 06:07

Noah_bean


People also ask

Can a column name have spaces?

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

How do you name a column in SQL with spaces?

DML SQL query with space in a column name When we run INSERT, UPDATE, and DELETE statements, we must use a square bracket or double quotes to handle the column name with space.

Can we have space in table name?

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

How do you call a column name with a space in Python?

You can refer to column names that contain spaces or operators by surrounding them in backticks. This way you can also escape names that start with a digit, or those that are a Python keyword.


1 Answers

Just put the name in backticks:

CREATE TABLE info (`Full Names` varchar(20), ...)

But that's no good handle for naming your columns.

like image 169
donald123 Avatar answered Oct 05 '22 01:10

donald123