When the column names in a SQL Server table are there any names that I should avoid using?

I remember when I was working with PHP several years ago, I could explode my application by calling the MySQL column "desc" or any other term that was used as an operator.

So, in general, are there any names I should avoid using table columns?

+3
source share
9 answers

As long as you surround each column name with "['and']", it really doesn't matter what you use. Even space works (try: []).

: '[' ']' , , , ; . ( SqlServer) : a-z, A-Z, 0-9, _, $, #.

+3

, , -

, , ,

create table 1abc (id int)

create table [1abc] (id int)

[] , , .

+3

, .

"" . , ( MSSQL)

(, , ), T_PERSON, V_PERSON, C_NAME .. , .

+2

SQL (, SELECT), .

+1

.

  • , , , ( )
  • , , :)

[square brackets] "double quotes", , , .

+1

, . , , SQL , .

+1

, :

SELECT [value], [select], [insert] FROM SomeTable

, , , , , "", !: -)

SQL , , , .

+1
+1

, :

UPDATE SET = 1 WHERE [id] IN (SELECT [id] FROM ids)

, , :

UPDATE SET = 1 WHERE id IN (SELECT [id] FROM ids)

, , ( ):

SELECT * FROM logs WHERE [id] IN (SELECT [id] FROM ids)

MSDE 2000 SP3 MS SQL (2000) Query Analyzer V 8.00.194

, , ​​ http://support.microsoft.com/kb/140215

.

0
source

Source: https://habr.com/ru/post/1712018/


All Articles