You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

SQL Server列命名规范:为何不建议在列名中添加数据类型后缀?

Why Suffixing SQL Server Columns with Data Types Isn’t a Common Practice

Great question! I’ve seen this exact pattern pop up in some older legacy systems, so I totally get why you’re curious about why it never became a standard in SQL Server. Let’s break down the key reasons experts and the wider community avoid this approach:

  • Data types belong to schema metadata, not business-focused column names
    Column names should first and foremost communicate business meaning, not technical implementation details. If you suffix Revenue with _f (for float), you’re locking that column to a specific data type. But business needs change—maybe later you realize you need to switch to decimal to avoid floating-point precision errors. Changing the column name to Revenue_d would force you to update every query, stored procedure, ETL script, and application that references it. That’s a massive maintenance headache that could’ve been avoided by keeping the name focused on the business value.

  • SQL Server gives you better ways to check data types
    You never need to guess a column’s data type from its name—SQL Server provides built-in tools to look this up directly. For example:

    -- Query column metadata
    SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'YourTableName';
    
    -- Or use a system stored procedure
    EXEC sp_help 'YourTableName';
    

    These methods are far more reliable than parsing suffixes, and they work for every table in your database without relying on a consistent naming pattern.

  • It violates the "Principle of Least Surprise"
    When developers see a column name like Organization_v or AccountNumber_i, their first question is usually "What does that suffix mean?" instead of immediately understanding the column’s purpose. Good naming should be intuitive—AccountNumber tells you everything you need to know about the data it holds at a glance, without forcing you to decode a suffix.

  • Community and official best practices discourage it
    Microsoft’s official SQL Server naming guidelines, along with widely accepted industry best practices, emphasize using descriptive, business-aligned names for columns. The focus is on making your schema readable and maintainable for other developers, not embedding technical metadata in names. Even ORMs like Entity Framework automatically map SQL data types to .NET types, so developers rarely need to reference the column’s data type directly in day-to-day work.

That said, you might occasionally see this pattern in temporary tables or data warehouse staging layers where quick, ad-hoc work is happening—but it’s almost never used in production business tables for the reasons above.

内容的提问来源于stack exchange,提问作者Chester Lim

火山引擎 最新活动