Create table query with manual AUTO_INCREMENT start value in MySQL?


Let us first create a table −

mysql> create table DemoTable1907
   (
   UserId int NOT NULL AUTO_INCREMENT,
   UserName varchar(20),
   UserAge int,
   UserCountryName varchar(20),
   PRIMARY KEY(UserId)
   )ENGINE=MyISAM,AUTO_INCREMENT=100;
Query OK, 0 rows affected (0.00 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable1907(UserName,UserAge,UserCountryName) values('Chris',26,'US');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1907(UserName,UserAge,UserCountryName) values('David',38,'UK');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1907(UserName,UserAge,UserCountryName) values('John',28,'AUS');
Query OK, 1 row affected (0.00 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable1907;

This will produce the following output −

+--------+----------+---------+-----------------+
| UserId | UserName | UserAge | UserCountryName |
+--------+----------+---------+-----------------+
|    100 | Chris    | 26      | US              |
|    101 | David    | 38      | UK              |
|    102 | John     | 28      | AUS             |
+--------+----------+---------+-----------------+
3 rows in set (0.00 sec)

Updated on: 30-Dec-2019

108 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements