create default

Specifies a value to insert in a column (or in all columns of a user-defined datatype) if no value is explicitly supplied at insert time.

Syntax

create default [or replace] [owner.]default_name 
	as constant_expression

Parameters

Examples

Usage

  • Bind a default to a column or user-defined datatype—but not an SAP ASE server-supplied datatype—with sp_bindefault.

  • You can bind a new default to a datatype without unbinding the old one. The new default overrides and unbinds the old one.

  • create default performs error checking for check constraints before it creates the default.

  • To hide the source test of a default, use sp_hidetext.

See also sp_bindefault, sp_help, sp_helptext, sp_rename, sp_unbindefault in Reference Manual: Procedures.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Use the default clause of the create table statement to create ANSI SQL-compliant defaults.

Permissions

Any user who impersonates the default owner through an alias or setuser cannot replace the default.

The permission checks for create default differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must have the create default privilege to create a default. To create a default for another user, you must have the create any default privilege.

To replace the default, you must be the default owner.

Disabled

With granular permissions disabled, you must be the database owner, a user with sa_role, or have the create default privilege to create a default. To create a default for another user, you must have sa_role.

To replace the default, you must be the default owner.

Auditing

Values in event and extrainfo columns of sysaudits are:

InformationValues
Event

14

Audit option

create

Command or access audited

create default

Information in extrainfo
  • Roles – current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Other information – NULL

  • Current value – NULL

  • Proxy information – original login name, if set proxy is in effect

  • or replace – for create or replace
Related reference
alter table
create rule
create table
drop default
drop rule
insert