1 / 9

Data Types

Data Types. Integer Int Smallint Tinyint Bit Packed Decimal Decimal(p,s) Floating Point Float Real Character Char(n) Varchar(n). Unicode Nchar(n) Nvarchar(n) Ntext Monetary Money Smallmoney Date and time Datetime Smalldatetime. Built In Data Types. Exotic Data Types.

zazu
Download Presentation

Data Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Types

  2. Integer Int Smallint Tinyint Bit Packed Decimal Decimal(p,s) Floating Point Float Real Character Char(n) Varchar(n) Unicode Nchar(n) Nvarchar(n) Ntext Monetary Money Smallmoney Date and time Datetime Smalldatetime Built In Data Types

  3. Exotic Data Types • Binary • Binary(n) • Varbinary(n) • Long text/BLOB • Text • Image • Numerics • Cursor • Timestamp • uniqueidentifier

  4. User-defined Data Type (UDT) • A user-defined data type provides a convenient way to guarantee consistent use of the underlying native data types for columns known to have the same domain of possible values. • For example, you want all phone numbers stored in the database the same way.

  5. UDT example Exec sp_addtype phone_number, ‘char(10)’, ‘not null’ Go to query analyzer and and define this datatype

  6. Sp_addtype • A system stored procedure that creates catalog entries for UDT’s • Syntax sp_addtype [ @typename = ] type,    [ @phystype = ]system_data_type    [ , [ @nulltype = ] 'null_type' ]     [ , [ @owner = ] 'owner_name' ]

  7. Using UDTs in a table • Create the following UDTs • Ssn char(11) not null • Birthdate datetime null • Use those datatypes to create this table • Empl • Name varchar(20) not null • SocNbr ssn • Bdate birthdate

  8. Testing UDTs • Write and insert statement to put data into the new table

  9. Limitations of UDTs • No defaults • No check constraint • No subtyping or inheritance

More Related