Search
 
SCRIPT & CODE EXAMPLE
 

SQL

data types sql

### String Data Types
CHAR(size)	FIXED length string of chars. Size from 0 to 255. Default 1.
VARCHAR(size) VARIABLE length string of chars. Size from 0 to 65535.
BINARY(size) Equal to CHAR(), but stores binary byte strings. Default 1.
VARBINARY(size)	Equal to VARCHAR(), but stores binary byte strings.
TINYBLOB	For BLOBs (Binary Large OBjects). Max length: 255 bytes
TINYTEXT	Holds a string with a maximum length of 255 characters
TEXT(size)	Holds a string with a maximum length of 65,535 bytes
BLOB(size)	For BLOBs. Holds up to 65,535 bytes of data
MEDIUMTEXT	Holds a string with maximum length of 16,777,215 characters
MEDIUMBLOB	For BLOBs. Holds up to 16,777,215 bytes of data
LONGTEXT	Holds string with maximum length of 4,294,967,295 characters
LONGBLOB	For BLOBs. Holds up to 4,294,967,295 bytes of data
ENUM(val1, val2, ...) String object of one or more values. Up to 65535 values.
SET(val1, val2, ...) String object of 0 or more values. Up to 64 values.

### Numeric Data Types
BIT(size)	A bit-value type. Size from 1 to 64. Default is 1.
TINYINT(size) Very small integer. Signed (-128, 127). Unsigned (0, 255).
BOOL	Zero is considered false, nonzero values are considered true.
BOOLEAN	Equal to BOOL
SMALLINT(size) Small integer. Signed (-32768, 32767). Unsigned (0, 65535). 
MEDIUMINT(size)	 Medium integer. Signed (-8388608, 8388607). Unsigned (0, 16777215).
INT(size)  Medium integer. Signed (-2147483648, 2147483647) Unsigned (0, 4294967295). 
INTEGER(size)	Equal to INT(size)
BIGINT(size)  Large integer. Signed (-9223372036854775808, 9223372036854775807). Unsigned (0, 18446744073709551615).
FLOAT(size, d)	Floating point number. Digits after decimal defined by d.
FLOAT(p) Floating point number. p chooses FLOAT(0, 24) or DOUBLE(25, 53).
DOUBLE(size, d)	Normal-size floating point. Digits after "," defined by d.
DOUBLE PRECISION(size, d)	 
DECIMAL(size, d) Exact fixed-point number.
DEC(size, d)	Equal to DECIMAL(size,d)

### Date and Time Data Types
DATE	A date. Format: YYYY-MM-DD. Range: ('1000-01-01' to '9999-12-31')
DATETIME(fsp)  Date and time. Format: YYYY-MM-DD hh:mm:ss. Range: ('1000-01-01 00:00:00' to '9999-12-31 23:59:59').
TIMESTAMP(fsp)  Seconds since Unix epoch ('1970-01-01 00:00:00' UTC). Format: YYYY-MM-DD hh:mm:ss. Range('1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC).
TIME(fsp)   Time. Format: hh:mm:ss. Range: ('-838:59:59' to '838:59:59')
YEAR            Year in four-digit format. Range (1901 to 2155)
Comment

sql data types

# Numeric Types
BIT	TINYINT SMALLINT INT BIGINT DECIMAL NUMERIC FLOAT REAL

# Date & Time Types
DATE TIME DATETIME TIMESTAMP YEAR

# Char & String Types (N) Denotes Unicode Versions
CHAR VARCHAR TEXT NCHAR NVARCHAR NTEXT

# Binary Data Types
BINARY VARBINARY IMAGE

# Misc
CLOB BLOB XML JSON
Comment

sql select data type of query

SELECT x.* INTO TMP1
FROM ( SELECT TOP 1 /* rest of your query expression here */ ) as x;

SELECT o.name AS obj_name, TYPE_NAME(c.user_type_id) AS type_name, c.*  
FROM sys.objects AS o   
JOIN sys.columns AS c  ON o.object_id = c.object_id  
WHERE o.name = 'TMP1';

DROP TABLE TMP1;
Comment

sql data types

• number(num) - whole numbers up to num digits
• number(num,num2) - num whole numbers up to num2 decimals
• char(num) - fixed length character/string
• varchar2(num) - used for varying length data
• date - full date
• currency - used for prices 
Comment

sql data type of query

DECLARE @query nvarchar(max) = 'select 12.1 / 10.1 AS [Column1]';
EXEC sp_describe_first_result_set @query, null, 0;
Comment

PREVIOUS NEXT
Code Example
Sql :: script to run SP_SPACESED on all tables in DB 
Sql :: oracle single row functions 
Sql :: mysql update column with value from another table 
Sql :: mysql find char in string 
Sql :: select * from mysql.proc 
Sql :: sql server udf performance 
Sql :: narural join 
Sql :: prestashop alter table if not exists 
Sql :: oracle sqlp update amount / quantity 
Sql :: code to move ietms from one table to another myswl 
Sql :: mysql conf.d exampel 
Sql :: multiple like values for single column postgres 
Sql :: How to calculate average of average salary of departments? 
Sql :: column value should show as latest using sql query 
Sql :: knex sqlite 
Sql :: sql transact create cursor with dynamic tables 
Sql :: SQL Combining Multiple Operators 
Sql :: postgre regex exactly 1 characters 
Sql :: sql server split string and insert into table select 
Sql :: mysql set user password for a range of ips 
Sql :: low level operator in dbms 
Sql :: ALV GRID events 
Sql :: Update All tables COLLATE DATABASE_DEFAULT 
Sql :: oracle repeat_interval 5 minutes 
Sql :: joins vs includes 
Sql :: check mysql password with docker container magento 2 
Sql :: sql convert 
Sql :: subconjuntos SQL 
Sql :: get id if is not equal in certain table 
Sql :: nodejs sql get one to many relationship as array 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =