MySQL uses these two fields, almost all of them are necessary.
Used to be automatically established, and now hand-built, it is necessary to find information to fix it.
Reference URL:
http://blog.csdn.net/Weicleer/article/details/47608289
Http://www.cnblogs.com/lhj588/p/4245719.html
==============================
After the table is established, how to insert values is also an issue.
==============================
When there is a self-growing primary key in the data table, when inserting a statement with an SQL INSERT statement with an ID column value record;
- If the value of the column is specified, the newly inserted value cannot be duplicated with the existing value and must be greater than the largest of the values;
- You can also do not specify the value of the column, only the value of the other columns inserted, let the ID or MySQL self-increment to fill in;
This is the case when inserting, two workarounds:
① can set the value of the ID to null or 0, so the child MySQL will do its own processing
② manually specify the columns that need to be inserted, and do not insert data for this field!
When inserting the current time value, the 2-2 method does not specify the column value and column data, and MySQL will take care of it.
For my scenario:
The table is like this:
CREATE TABLE' Pmlog ' (' ID ')int( One) not NULLauto_increment, ' Deployname 'varchar(255) not NULL, ' AppName 'varchar(255), ' SiteName 'varchar(255), ' ipAddress 'varchar(255) not NULL, ' Envtype 'varchar(255), ' UserName 'varchar(255) not NULL, ' Operationtype 'varchar(255), ' Operationno 'varchar(255), ' Logcontent 'varchar(2048), ' Logdatetime 'datetime NULL DEFAULT Current_timestamp, PRIMARY KEY(' id '),) ENGINE=InnoDBDEFAULTCHARSET=UTF8 COLLATE=Utf8_unicode_ci;
When inserting data manually, use the following command.
INSERT into' Pmlog ' (Deployname, AppName, SiteName, ipAddress, Envtype, UserName, Operationtype, Operationno, logcontent)VALUES('DeployName5','AppName5','SiteName5','ipAddress1.3.5','Envtypefat','USERNAMECCC','OperationType1','OperationNo5','logcontentffffffff55555555fffffffffff');
MySQL builds a self-increment primary key insert, and automatically inserts the current time