If i have my SQL create statement as follows;
CREATE TABLE TABLENAME12
(
TAB_ID INT NOT NULL AUTO_INCREMENT,
NAME_FIRST NVARCHAR(200),
TYPE NVARCHAR(200),
PRIMARY KEY( TAB_ID )
);
and if i want to Insert values to it, should i enter TAB_ID too ? Since it’s auto increment.
When i INSERT INTO SWM_SALES_FEEDBACK VALUES (1,'Jerry','ty'); It gets inserted if i don’t specify the primary key INSERT INTO SWM_SALES_FEEDBACK VALUES ('Jerry','ty'); i get the following error :
ERROR 1136 (21S01): Column count doesn't match value count at row 1
1.) What is the point of having AUTO_INCREMENT if it doesn’t get auto incremented.
2.) If i have a field called:
BIRTH_TIME DATE,
How should i INSERT value to this field since it’s DATE type
Point 1If you don’t want to store all fields in DB then you have to specify those column names before
VALUESclause as shown below.In your case, statement should be
Point 2If you have field as DATETIME, TIMESTAMP as datatype, you can enter date as
Format is
yyyy-mm-dd hh:mm:ssIf you want to store the current time of the system in DB, you could use
NOW()as shown below.