DF038: The constraint name is not explicitly specified.

The topic describes the DF038 T-SQL code analysis rule.

Category

NAMING CONVENTIONS

Message

The constraint name is not explicitly specified.

Description

To facilitate database maintenance, it is recommended to explicitly name constraints so that they can be easily referenced when needed.

Additional information

When the constraint name is not explicitly specified in SQL, the DBMS automatically generates a default name for the constraint, typically combining the table name with a system-generated identifier. This can lead to less readable and harder-to-manage schema definitions, making tasks like error resolution and constraint modification more challenging due to the non-descriptive and unpredictable default names.

Noncompliant code example

CREATE TABLE dbo.Customers(
  CustomerId INT PRIMARY KEY CLUSTERED,
  CustomerName VARCHAR(255) NOT NULL
  );

Compliant solution

CREATE TABLE dbo.Customers(
  CustomerId INT CONSTRAINT PK_Customers PRIMARY KEY CLUSTERED,
  CustomerName VARCHAR(255) NOT NULL
  );

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?