0

Is it bad practice to have spaces in between words in SQL entries?

Food Table

id  name         descriptions
--  -----------  ------------
1   large pizza  very large

or do you need underscores?

1
  • So... if you're creating a database of old books and their full content, you'd use _ instead of spaces? To_be_or_not_to_be,_that_is_the_question doesn't look quite as nice and readable... Commented Mar 19, 2012 at 21:53

3 Answers 3

6

Data is data. Your RDBMS won't care about spaces in the values in its string/text/varchar columns.

Sign up to request clarification or add additional context in comments.

1 Comment

Steve - Text is a type of data. If it makes more sense to you, feel free to edit my answer.
0

It makes no real difference. Maybe some more typing when entering queries in remembering to place block quotes around field names (i.e. [your long fieldname]).

1 Comment

I think the question was about the data not the field names
0

Spaces in the records aren't a concern at all. Quite the opposite. Adding underscores would only mean that the developer would have to replace them in code. (grumble)

Spaces in the column names can add extra overhead and grumbling for the developer accessing the data. (For example, in SQL Server, you need to enclose them in square brackets in sql statements.)

3 Comments

so for field names (column names), one should always use the underscore?
It depends on the naming convention in your company, but your business will likely have their own standard to ensure consistency. If you're on your own it's up to you. I prefer CamelCase to for field names. (FirstName, LastName) instead of underscores (First_Name, Last_Name)
Ok, and on the topic of naming conventions for fields names, if I have a Dog's table, should my field names be DogName | DogColor | DogCollar | Dog'sFavoriteFood etc.... or can it just be name | color | collar | FavoriteFood

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.