HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Can default object names be changed?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
cannamesdefaultobjectchanged

Problem

Sooner or later, a db developer will come across, and possibly use, a naming scheme for many objects like foreign keyes, default constraints etc.

Let's consider this example: Name all foreign keys as:

FK__[name of source table]__[name of source col]__ref__[name of master table]__[name of master column]

What kind of parametrization/external programs could be used to achieve having such a name as default, when for example using a create table statements which mentions the fk but does not explicitly provide a constraint name?

Solution

What kind of parametrization/external programs could be used to
achieve having such a name as default, when for example using a create
table statements which mentions the fk but does not explicitly provide
a constraint name?

There's no way to change the default name generated when the DDL doesn't contain a name. The only thing you can do is to run a batch process to identify non-compliant objects and perhaps drop and recreate them.

Context

StackExchange Database Administrators Q#250010, answer score: 5

Revisions (0)

No revisions yet.