
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Can we insert records in a MySQL table without auto_increment values?
Yes, we can insert without the auto_increment since it gets inserted on its own. Let us first create a table −
mysql> create table DemoTable1479 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeSalary int -> ); Query OK, 0 rows affected (0.86 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1479(EmployeeSalary) values(6800); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1479(EmployeeSalary) values(5600); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1479(EmployeeSalary) values(5700); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1479(EmployeeSalary) values(6900); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1479(EmployeeSalary) values(15000); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1479;
This will produce the following output −
+------------+----------------+ | EmployeeId | EmployeeSalary | +------------+----------------+ | 1 | 6800 | | 2 | 5600 | | 3 | 5700 | | 4 | 6900 | | 5 | 15000 | +------------+----------------+ 5 rows in set (0.00 sec)
- Related Articles
- Auto insert values into a MySQL table in a range?
- Can we insert values without mentioning the column name in MySQL?
- How can we insert data into a MySQL table?
- How to make MySQL table primary key auto increment?
- How can we update values in a MySQL table?
- How can we insert a new row into a MySQL table?
- How can we insert values into a table with the help of MySQL self-computed output?
- How to create a table with auto-increment column in MySQL using JDBC?
- Insert all the values in a table with a single MySQL query separating records by comma
- How can we specify default values in MySQL INSERT statement?
- Truncate a MySQL table and then set a custom value to auto increment
- Set auto increment initial value for MySQL table using ALTER command
- How to auto increment with 1 after deleting data from a MySQL table?
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- How can we insert current date automatically in a column of MySQL table?

Advertisements