In MySql, we can create a column that contains a sequence of numbers(1,2,3 and so on) by using the AUTO_INCREMENT attribute. The AUTO_INCREMENT attribute is used when we need to create a unique number in a table . Every column with “AUTO_INCREMENT” set does not need a value, as the database will provide it with the next sequential number.
A DEFAULT value clause in a data type specification explicitly indicates a default value for a column. The use of DEFAULT is to specify the default value for a named column is permitted only for columns that have a literal default value, not for columns that have an expression default value.
Example:
CREATE TABLE IF NOT EXISTS products ( productid INT UNSIGNED AUTO_INCREMENT primary key, description Varchar(30) DEFAULT ' ', quantity INT(6), price DECIMAL(7,2))
Inserting row into the products table
Example:
insert into products values (1001,'Mouse',10,325) Applying autoincrement and default to the insert command insert into products (description, quantity, price) values('keyBoard',5,300) insert into products (description, quantity, price) values ('SMPS',1,99999.99)
Now click on the Browse Tab, to show the rows inserted…
Now, check with last record, the default value of price column has been stored with 99999.99.