AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
HTML Tutorial

SQL create table primary key autoincrement


The SQL CREATE TABLE Statement is used to create a new table in a SQL database.

AUTO INCREMENT fields are used for auto generating values for particular column whenever new row is being inserted.

SQL create table - how to create - example


CREATE TABLE Syntax

Example 1: Syntax
CREATE TABLE table-name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
   ....
);


The following example creates a table called "Users" that contains five columns: ID, Name, Surname, Address, and City:

Example 1: CREATE TABLE
CREATE TABLE Users (
    ID int,
    Name varchar(255),
    Surname varchar(255),
    Address varchar(255),
    City varchar(255) 
);

SQL create table primary key autoincrement - Example - How to create

The following SQL statement defines the "ID" column to be an auto-increment primary key field in the "Persons" table:

Example 2: (MySQLi Procedural)

CREATE TABLE Persons (
    ID int NOT NULL AUTO_INCREMENT,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID)
);


MySQL uses the AUTO_INCREMENT keyword to perform an auto-increment feature.
By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record.


SQL create table
SQL create table primary key autoincrement - sql tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Home - Database
SQL - Database
SQL Syntax
SQL Select Data
SQL Insert Data
SQL Update
SQL Delete Row
PHP mysqli_query()
SQL order
SQL Create Database
SQL Display Data
SQL Count()
SQL mysqli_connect
SQL create table
SQL Where And & Or
SQL like Syntax
SQL Between Operator
SQL IN Operator
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.