Jumat, 16 Agustus 2024

Create Table In SQL Server

Requirements

SQL Server has been installed and running.

This task requires CREATE TABLE permission in the database, and ALTER permission on the schema in which the table is being created.

This task requires Database NWind on SQL Server.

Syntax

CREATE TABLE [database_name.][schema_name.]table_name (

    column_name1 data_type NOT NULL PRIMARY KEY,

    column_name2 data_type [NULL | NOT NULL],

    column_name3 data_type [NULL | NOT NULL],

    ...,

);

Create Table In SQL Server Database Step

  1. After open SQL Server Management Studio (SSMS) or other tools to write Transact-SQL (T-SQL)
  2. Connect to an instance of Database ( for example : NWind ).
    USE NWind;
  3. Type the following example into the query window and select Execute.
    CREATE TABLE NWind.dbo.Shippers (
        ShipperID INT NOT NULL,
        CompanyName VARCHAR(50) NOT NULL,
        Address VARCHAR(100) NULL,
        Phone VARCHAR(50) NULL,
        CONSTRAINT PK_ShipperID PRIMARY KEY (ShipperID)
    );
  4. then execute the query

Bibliography

https://learn.microsoft.com/en-us/

https://www.devart.com/

SQL series;No Starch Press

SQL For Dummies;Allen G. Taylor et. al.;Wiley

SQL Server series;Microsoft Press

database, sequel, table sample, structure query language, programmer, administrator, technical support, data, system 

Related Post

Tidak ada komentar:

Posting Komentar

Various Other Posts