Create table function in SQL - Create Table

Working with databases is directly related to changing tables and the data contained in them. But before starting an action, tables must be created. To automate this process, there is a special SQL function - "CREATE TABLE".

First thing!

Before you understand the process of creating tables using the MS SQL command "CREATE TABLE", you should dwell on what you need to know before you start using the function.

, - , , , . (a-z), , , . 18 .

sql create table




, : , . , .

, .





, . , SQL "CREATE TABLE". , . :

CREATE TABLE table_name

({column_name datatype [DEFAULT expression] [column_constraint] …| table_constraint}

[,{column_name datatype [DEFAULT expression] [column_constraint]…| table_constraint}]…)

, , :

  • table_name -
  • column_name -
  • datatype - ,
  • DEFAULT - , .

:

  • colum_constraint -
  • table_constraint -

.

SQL "CREATE TABLE", . , .

, , : NULL ( ) NOT NULL ( ).

, . . , , , "CREATE TABLE" , "Primary key" . .









ms sql create table




Primary key "FOREIGN KEY". , , , , . .

, CHECK. . , , "" "" "".

, SQL "CREATE TABLE" , .

, , CREATE TABLE (SQL). , , , :

CREATE TABLE Custom

(ID CHAR (10) NOT NULL Primary key,

Custom_name CHAR (20),

Custom_address CHAR (30),

Custom_city CHAR (20),

Custom_Country CHAR (20),

ArcDate CHAR (20))

create table sql example




As you can see, the parameter of the possible absence of a value in the cell (NULL) can be omitted, since it is used by default.




All Articles