Environment: SQL Server 2008 R2
An exact numeric data type that uses integer data.
bigint
Integer data (all numbers) from -2^63 (-9223372036854775808) to 2^63-1 (9223372036854775807). The storage size is 8 bytes.
Int
Integer data (all numbers) from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647). The storage size is 4 bytes. The SQL-92 synonym for int is integer.
smallint
Integer data from -2^15 (-32,768) to 2^15-1 (32,767). The storage size
) is equivalent to the fact that text and Ntext,varchar (max) can store up to 2G of data (later versions may be more), but text and ntext do not support "=", "Left ()" , like, and varchar (max) and nvarchar (max) support, and Microsoft may remove the text and ntext types in SQL Server later, you should use varchar (max) and nvarchar (max) Replace text and ntext. 5.datetime and smalldatetime: DateTime: Date
1.1 Introduction
In SQL Server, a user-defined table type refers to a type defined by the user that represents a table structure definition. You can use a user-defined table type to declare a table-valued parameter for a stored procedure or function, or to declare a table variable that you want to use in a batch or in the body of a stored procedure or function.
To create a user-defined table type, use the Create TYPE statement. To ensure that data f
server| Data | data type (1) char, varchar, text and nchar, nvarchar, ntext
The length of char and varchar is between 1 and 8000, the difference being that char is a fixed-length character data, and varchar is variable-length character data. The so-called fixed-length is constant, when the input data length does not reach the specified length will be automatically filled with English spaces behind it, so that length to the appropriate length, and vari
SQL Server contains several different types of pages to meet the needs of your data store. Regardless of the type of page, their storage structure is the same. Each data file contains a significant number of 8KB pages, each page has 8192bytes available, each page has 96byte for the header storage, and the rest of the space
is used to store the actual data, at the end of the page is the data row offset arra
. Querying the fields and data types of a tableSelect Column_name,data_type from Information_schema.columnsWHERE table_name = ' table name '9. Using TransactionsSQL Server transactions can be used when working with temporary SQL statements on database tables to prevent errors from being detected after data manipulation.Start a transactionBegin TranInsert into TableName Values (...)If the SQL statement opera
Search the internet about the data types of comparison, there are almost no three database comparison, I wrote some of the comparison of the fields, if there is a wrong place, please feel free.
Java fields
Oracle Fields
MySQL Field
SQL Server Fields
Int
Number
Int
Int
Java.lang.double
Number (P,s)
Double
Float
Label:A data table is made up of multiple columns, and you must specify the data type of each column when you create the table. The following is a list of usage rules for common SQL Server data types .
Integer type
Int
The storage range is an integer between 2,147,483,648 and 2,147,483,647, and this type is often set by the primary key column. (4 bytes per value)
Although int is still the primary integer data type in SQL Server 2000, SQL Server 2000 is a new addition to the integer data type bigint, which applies to situations where integers exceed the int data range.
The int data type represents a range of values from -2^31 to 2^31-1, that is, you can use INT data types to express integers between 2,147,483,648 and 2,14
The Unicode character set is created to resolve incompatible problems with character sets, all of which are represented in two bytes, which is also represented in two bytes.
If still for this tangle, just look at the back of the commentary, make a decision.
In general, if you use the Chinese or other special characters, I will use the type of n beginning, otherwise the direct use of the Var start.
What is the difference between varchar and nvarchar in SQL
In our daily development process, when designing a database, we often encounter problems with selecting data types, choosing what type of data is most appropriate, and then choosing the corresponding CLR type when we create the corresponding entity in the project. In response to these questions, this article was born.
SQL Server data types
Server data type
Description
Synonymous
Bit
1 digits, value 0 or 1
Int
Integer
4 bytes, value is -2^31~2^31-1
Smallint
2 bytes, value is -2^15~2^15-1
Tinyint
1 bytes, value is 0~255
Decimal (P,s)
numeric data, with a fixed precision of p, and a width of s
Numeric
Money
8 bytes, store currency type, value is -2^63~2^63-1
Small Money
4 bytes, store currency type, value is -214748.3648~+214748.3647 approximate numeric data type
Float (N)
n between 1~24,
Label:Snapshot publication:The publisher sends a snapshot of the published data to the Subscriber at a predetermined interval.Transactional publications:After the subscriber receives the initial snapshot of the published data, the publisher streams the transaction to the Subscriber.Peer Publishing:Peer publishing supports multi-master replication. The publisher streams the transaction to all peers in the topology. All peer nodes can read and write changes, and all changes are propagated to all n
created when the type is created, and you cannot use the ALTER statement.Declare table variables according to table typeDECLARE @table_variable type_name;Table variablesA table variable is a type of data that has the structure of a table and the functionality of some tables. It can be queried, inserted, updated, deleted. It is important to note that table variables cannot be used with select: INTO statement Insert dataBut temporary tables can. Table variables can be used in combination with sto
Tags: bar type convert int mil false cond reserved--HarThe time (2) type retains two bits of milliseconds, and after the application converts the time (2) type to int to SQL Server, the following two methods can convert int to time (2):--Method 1
DECLARE @T int
SET @T = 10455836
SELECT DATEADD (Hour, (@t/1000000)%,
DATEADD (minute, (@T /10000)%,
DATEADD (second, (@t/100)%,
DATEADD (millisecond, (@T%) *, cast (' 00:00:00 ' asTime (2))))
--Method 2
SELE
Tags: fixed har char trim definition length take number requires VarThe length of the char type is immutable in SQL Server, and the length of the varchar is variable.When depositing data:If the data type is char, when a fixed length of a field is defined, if the length of the stored data is less than the length of char, then the length of data stored in the data is still defined field length, the data format will be stored in the data and space;If the
. No_log and truncate_only are synonymous.
Here's a question, what is the activity log, Microsoft's explanation is: The portion of the log file from the first log record that must exist to ensure that the database is successfully rolled back to the last written log record is called the active part of the log, which is the activity log. This is the section of the log required for full database recovery. You can never truncate any part of the activity log. DBCC shrinkdatabase shrinks al
of digits that can be stored (left and right of the decimal point). P must be a value between 1 and 38. The default is 18. The s parameter indicates the maximum number of digits stored to the right of the decimal point. s must be a value between 0 and P. The default is 0. 5-17 bytessmallmoney The currency data between -214,748.3648 and 214,748.3647. 4 bytesMoney data between -922,337,203,685,477.5808 and 922,337,203,685,477.5807. 8 bytesfloat (n) floating precision digital data from -1.79e + 30
Create function fun_a () #标题函数, create function Fun_name () returns OUTPUT_TYPE as begin return value end;returns intAsBeginreturn 1;EndGoCreate function Fun_b () #多语句用户定义函数, create function Fun_name () returns @value table (Colum_list) as begin return; end
Returns @tb table (ID int, Name nvarchar (8))AsBeginInsert into @tb (id,name) VALUES (1, ' 111 '), (2, ' 222 ');ReturnEndGoCreate function Fun_c () #内联用户定义函数, create function Fun_name () returns table as return select ...;Returns tableAsRe
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:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.