SQL Server Create Table SQL Generator
Online SQL Server Create Table SQL Generator allows you to visually create SQL statement for creating table in SQL Server. Simply create table columns by selecting data type and other properties, resulting SQL statement will be syntax highlighted for easy reading.
Bookmark:
SQL Server Create Table SQL Generator
Creating a table in Microsoft SQL Server is relatively straight forward. Being able to design a well thought out database that will scale to meet the needs of a large scale enterprise is a very challenging undertaking. This online Microsoft SQL Server Create Table SQL Generator tools allows beginners to learner the fundamentals of SQL Server table creation SQL statement. This online table creation SQL generator tool does not provide all the features in SQL server. But this tool has most of the basic features need to create table in SQL Server. SQL Server Create Table SQL Generator is an online tool that allows you to visually create SQL statement for creating table in SQL Server. We are using Microsoft Silverlight technology to improve the online SQL Server Create Table SQL Generator tool performance and make it easier for end users. Generated SQL statement will be syntax highlighted with standard SQL (Structured Query Language) reserved words and with other syntax.
Microsoft SQL Server Create Table SQL Syntax
CREATE TABLE table_name ( { < column_definition > | < table_constraint > } [ ,...n ] ) < column_definition > ::= { column_name data_type } [ { DEFAULT constant_expression | [ IDENTITY [ ( seed , increment ) ] ] } ] [ ROWGUIDCOL ] [ < column_constraint > [ ...n ] ] < column_constraint > ::= [ CONSTRAINT constraint_name ] { [ NULL | NOT NULL ] | [ PRIMARY KEY | UNIQUE ] | REFERENCES ref_table [ ( ref_column ) ] [ ON DELETE { CASCADE | NO ACTION } ] [ ON UPDATE { CASCADE | NO ACTION } ] } < table_constraint > ::= [ CONSTRAINT constraint_name ] { [ { PRIMARY KEY | UNIQUE } { ( column [ ,...n ] ) } ] | FOREIGN KEY ( column [ ,...n ] ) REFERENCES ref_table [ ( ref_column [ ,...n ] ) ] [ ON DELETE { CASCADE | NO ACTION } ] [ ON UPDATE { CASCADE | NO ACTION } ] }
Microsoft SQL Server Create Table SQL Syntax - Arguments
Argument | Description |
---|---|
table_name | The name of the new table. Table names must comply with the rules for identifiers. The table_name must be unique within the database. A table_name can contain a maximum of 128 characters. |
column_name | The name of a column in the table. Column names must comply with the rules for identifiers and must be unique in the table. |
data_type | Specifies the column data type. For information about data types. |
DEFAULT | Specifies the value provided for the column when a value is not explicitly supplied during an insert action. DEFAULT definitions can be applied to any column, except those defined by the IDENTITY property. DEFAULT definitions are removed when the table is dropped. A constant value can be used as a default. |
IDENTITY | Indicates that the new column is an identity column. When a new row is added to the table, SQL Server provides a unique, incremental value for the column. Identity columns are generally used in conjunction with PRIMARY KEY constraints to serve as the unique row identifier for the table. The IDENTITY property can be assigned only to int columns. Only one identity column can be created per table. Bound defaults and DEFAULT constraints cannot be used with an identity column. You must specify both the seed and increment or neither. If neither is specified, the default is (1,1). |
Seed | The value used for the first row that is loaded into the table. |
increment | The incremental value added to the identity value of the previous row that is loaded. |
NULL | NOT NULL | Keywords that specify whether null values are permitted in the column. NULL is not strictly a constraint but can be specified in the same manner as NOT NULL. |
PRIMARY KEY | A constraint that enforces entity integrity for a particular column or columns using a unique index. Only one PRIMARY KEY constraint can be created per table. |
Microsoft SQL Server Data Types
Each column in a table in a Microsoft SQL Server database supports a set of data types that specify the type of data that the column can hold.
Data Type | Description |
---|---|
bigint | Integer (whole number) data from -2^63 (-9,223,372,036,854,775,808) through 2^63-1 (9,223,372,036,854,775,807). Storage size is 8 bytes. |
integer | Integer (whole number) data from -2^31 (-2,147,483,648) through 2^31-1 (2,147,483,647). Storage size is 4 bytes. |
smallint | Integer data from -32,768 to 32,767. Storage size is 2 bytes. |
tinyint | Integer data from 0 to 255. Storage size is 1 byte. |
bit | Integer data with a value of either 1 or 0. Storage size is 1 bit. |
numeric (p, s) Synonyms: decimal(p,s) and dec (p,s) |
Fixed-precision and scale-numeric data from -10^38+1 through 10^38-1. The p variable specifies precision and can vary between 1 and 38. The s variable specifies scale and can vary between 0 and p. Storage size is 19 bytes. |
money | Monetary data values from (-2^63/10000) (-922,337,203,685,477.5808) through 2^63-1 (922,337,203,685,477.5807), with accuracy to a ten-thousandth of a monetary unit. Storage size is 8 bytes. |
float | Floating point number data from -1.79E +308 through 1.79E+308 Storage size is 8 bytes. |
real | Floating precision number data from -3.40E+38 through 3.40E+38. Storage size is 4 bytes. |
datetime | Date and time data from January 1, 1753, to December 31, 9999, with an accuracy of one three-hundredth second, or 3.33 milliseconds. Values are rounded to increments of .000, .003, or .007 milliseconds. Stored as two 4-byte integers. The first 4 bytes store the number of days before or after the base date, January 1, 1900. The base date is the system's reference date. Values for datetime earlier than January 1, 1753, are not permitted. The other 4 bytes store the time of day represented as the number of milliseconds after midnight. Seconds have a valid range of 0-59. |
national character(n) Synonym:nchar(n) |
Fixed-length Unicode data with a maximum length of 4000 characters. Default length = 1. Storage size, in bytes, is two times the number of characters entered. |
national character varying(n) Synonym:nvarchar(n) |
Variable-length Unicode data with a length of 1 to 4000 characters. Default length = 1. Storage size, in bytes, is two times the number of characters entered. |
ntext | Variable-length Unicode data with a maximum length of (2^30-2)/2 (536,870,911) characters. Storage size, in bytes, is two times the number of characters entered. |
nchar | Fixed-length Unicode character data of n characters. n must be a value from 1 through 4,000. The storage size is two times n bytes. |
binary(n) | Fixed-length binary data with a maximum length of 8000 bytes. Default length = 1. Storage size is fixed, which is the length in bytes declared in the type. |
varbinary(n) | Variable-length binary data with a maximum length of 8000 bytes. Default length = 1. Storage size varies. It is the length of the value in bytes. |
image | Variable-length binary data with a maximum length of 2^30-1 (1,073,741,823) bytes. Storage is the length of the value in bytes. |
uniqueidentifier | A globally unique identifier (GUID). Storage size is 16 bytes. |
IDENTITY [(s, i)] | This is a property of a data column, not a distinct data type. Only data columns of the integer data types can be used for identity columns. A table can have only one identity column. A seed and increment can be specified and the column cannot be updated. s (seed) = starting value i (increment) = increment value |
ROWGUIDCOL | This is a property of a data column, not a distinct data type. It is a column in a table that is defined by using the uniqueidentifier data type. A table can have only one ROWGUIDCOL column. |
Timestamp/rowversion | This is an automatically generated unique binary number. Storage size is 8 bytes. |
Online Microsoft SQL Server Create Table SQL Generator:
- Purpose of this Tool : Generate SQL for MS SQL Server, SQL Create Table Generator, Learning SQL
- Intended Audience : SQL Programmers, Database Administrators, SQL Server Administrators, Software Developers, SQL Testers
External Resources: