HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
HTML Tutorial

CSS 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

3293. SQL update - SQL update select, sql tutorial
SQL update - SQL update select sql tutorial
https://www.agernic.com/sql-tutorial/sql-update-sql-update-select.html

2580. SQL MIN - SQL Tutorial

http://www.sql-tutorial.net/SQL-MIN.asp

2587. SQL Training - SQL Tutorial

http://www.sql-tutorial.net/sql-training.asp

2564. SQL AND & OR - SQL Tutorial

http://www.sql-tutorial.net/SQL-AND-OR.asp

3287. SQL COUNT(), AVG() and SUM() Functions, sql tutorial
SQL COUNT(), AVG() and SUM() Functions sql tutorial
https://www.agernic.com/sql-tutorial/sql-count-avg-and-sum-functions.html

3284. PHP mysqli_query() Function - mysqli query, sql tutorial
PHP mysqli_query() Function - mysqli query sql tutorial
https://www.agernic.com/sql-tutorial/php-mysqli_query-function-database-mysqli.html

Your add here
How to get PHP errors to display?
How to prevent sql injection in php mysqli
How do I get PHP errors to display - PHP error_reporting()
mysql_query(): The mysql extension is deprecated and will be removed i
Function eregi_replace() is deprecated in php - How to fix
PHP delete an element from an array
Uncaught Error: Call to undefined function MYSQL_NUM_ROWS() in
Deprecated: mysql_connect() mysql extension is deprecated and will be
mysqli_fetch_array() expects parameter 1 to be mysqli_result boolean g
SQL IN Operator - example
SQL BETWEEN Operator
SQL like syntax and example
SQL WHERE AND & OR multiple conditions
SQL create table primary key autoincrement
PHP mysqli_connect () Function
SQL COUNT(), AVG() and SUM() Functions
Display data from SQL database with MySQLi into php - html table
SQL CREATE DATABASE - example
SQL mysql order by columns, by date, by asc, by desc, random with PHP
PHP mysqli_query() Function - mysqli query
SQL delete row - SQL delete table
SQL update - SQL update select
Insert into SQL - Insert into table SQL - Insert data in sql
Login in PHP - simple login script with PHP MYSQL