Home

Option to always prefix table names with schema?

The default behavior when creating a database connection is to prefix table names with the schema only if a conflict occurs--that is, there are two same-named tables in different schemas.

Is there an option to always prefix table names with the schema? This would be beneficial for several reasons:

  1. The T-SQL convention in queries is to always prefix with the schema when a non-dbo schema exists. customer.Discounts, vendor.InterestRates, customer.Addresses
  2. Consistently prefixing tables reduces cognitive load. customer_Discounts, vendor_InterestRates, Addresses <== customer or vendor addresses?
  3. Schemas often provide domain and business context

If I haven't just missed an existing option, from the outside, this seems like a reasonable feature to implement since there's already a condition for prefixing. I'm hoping it would be as easy as "if hasConflict or alwaysPrefix then ..."

Comments

  • Another reason to allow always prefixing table names is if the source schema changes. This happened to me today. A few tables that previously had conflicts no longer did--or maybe on connection refresh they were chosen as the "primary" table. Either way, my code was broken because the table names had changed from prefixed to non-prefixed.

Sign In or Register to comment.