Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite3 square brackets in a select statement

Tags:

sqlite

In the following piece of code, what is the purpose of the square?

SELECT Value, [Default] AS Selected FROM SKUOptVal WHERE SKUOptID = ?

Cheers.

This code is written for SQLite3.

like image 783
Jason Avatar asked Oct 15 '25 13:10

Jason


2 Answers

It's an identifier. It's the same as saying "Default". It's included for compatibility with MS Access. Since Default is a keyword in SQL, it needs to be quoted if used as an identifier, as it is here.

like image 62
Dan Avatar answered Oct 18 '25 17:10

Dan


The column is named default, which is the same as an SQL keyword. Thus, the brackets are used to denote we are referring to the column default and not the keyword default.

like image 35
Gerald P. Wright Avatar answered Oct 18 '25 15:10

Gerald P. Wright