What are User Defined Datatypes?

User Defined Datatypes

User defined data types are most commonly used when consistency among several tables storing the same type of data is desired. User defined data types can also be used when several tables must store the same type of data in a column .Consistency in terms of same data type, length, and null ability is required. The user defined data type in SQL is based on system data type. When a user defined data type is created it must have a name, a system data type, whether or nor it can accept NULL values.
Syntax:
Sp_addtype is used to create a user defined data type in transact SQL.

Example:
To create a user defined data type for postal code.
Sp_addtype postal_Code, ‘varchar(10)’ , ‘NOT NULL’
Difference between a primary key and a unique key
Both enforce uniqueness of the column. By default primary key creates a clustered index........
What is bit datatype?
Bit datatype is used to store boolean information like 1 or 0 (true or false)........
Define candidate key, alternate key, composite key
Candidate key: A column or a set of columns can be called as candidate key if they i dentify each row of a table uniquely........
Post your comment