Data Type of T-SQL

Source: Internet
Author: User
Use  Test  Go  Create   Table DBO. [  Table_datetype_tinyint  ]  (  [  F_d_tinyint  ]   Tinyint   Not   Null  )  On  [  Primary  ]  Go  --  Input statement  --  Enter 256 data entries into the test table  Declare   @ I   Tinyint  Select   @ I  =  0  Set Nocount On  While ( @ I  <=  255  )  Begin      Insert   Into Test. DBO. table_datetype_tinyint Values ( @ I  );  If ( @ I  <=  254 )  Select   @ I  =  @ I  +  1      Else          Break  ;  End   Set Nocount Off   Select   *   From  Test. DBO. table_datetype_tinyint --  Query the page distribution of a table  DBCC Traceon ( 3604  )  Go  DBCC  Extentinfo (test, table_datetype_tinyint)  Go  --  Query data page content  DBCC Traceon ( 3604  )  Go  DBCC Page (test, 1 , 155 , 1 ) --  Tinyint 9  DBCC  Page (test ,)  --  Analysis  /*  ------------------------------------------- The data stored in the tinyint data type itself requires only one byte, but when it is stored as a table column, it requires nine bytes to store one of the nine Bytes: it is one byte of the data itself: because no index is created, the table data is stored in the heap mode, and the null margin is three Bytes: the space graph is used to indicate that the column is empty, the calculation method is 2 + (total number of columns + 7)/8, and an integer is taken up. Here, one table column is displayed, so the calculation result is 34 Bytes: Column Title used to store data rows */  --  The above is only an example. You can refer to the task type. 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.