Is prefixing each field name in a table with abbreviated table name a good practice?

后端 未结 14 2033
-上瘾入骨i
-上瘾入骨i 2020-12-16 19:26

Do you prefix each field in a table with abbreviated table name?

Example:

Table: User

Fields:
user_id
user_name
user_password

Or d

14条回答
  •  孤城傲影
    2020-12-16 20:14

    The prefix variant just takes longer to write and makes it harder to read sql statements with many fields.

    Even when you are selecting from several tables, this gives you only the benefit of not having to prefix ambiguous fields with the table name. But

    SELECT user.name, image.name FROM user, image
    

    is not very different from

    SELECT user_name, image_name FROM user, image
    

    The benefit of havong no ambiguous fields in your queries is quickly eaten up by the overhead of having to type the table name each time you are using a column name.

提交回复
热议问题