Build table:
CREATE TABLE ' sj_projects ' (
' id ' int (one) not NULL auto_increment,
' title ' varchar (255) Not NULL DEFAULT ' COMMENT ' project name ',
' platform_id ' int (one) not NULL DEFAULT ' 0 ' COMMENT ' platform ID ',
' unique_id ' varchar (255) Not NULL DEFAULT ' COMMENT ' project and data unique ID ',
' Repayway ' varchar (255) Not NULL DEFAULT ' COMMENT ' repayment method ',
' Profit ' decimal (5,2) not NULL DEFAULT ' 0.00 ' COMMENT ' annual yield ',
' Speed ' decimal (5,2) is not NULL DEFAULT ' 0.00 ' COMMENT ' Progress ',
' Frequency ' int (one) not NULL DEFAULT ' 0 ' COMMENT ' investment number ',
' Amount ' decimal (20,2) not NULL DEFAULT ' 0.00 ' COMMENT ' Financing amount ',
' Res_amount ' decimal (20,2) not NULL DEFAULT ' 0.00 ' COMMENT ' remaining available amount ',
' Invtime ' timestamp not NULL DEFAULT ' 0000-00-00 00:00:00 ' COMMENT ' project investment start time ',
' Endtime ' timestamp not NULL DEFAULT ' 0000-00-00 00:00:00 ' COMMENT ' project investment End Time ',
' Turntime ' timestamp not NULL DEFAULT ' 0000-00-00 00:00:00 ' COMMENT ' Project repayment time (customer payment time) ',
' Term ' varchar (a) Not NULL DEFAULT ' ' COMMENT ',
' Type ' int (one) not NULL DEFAULT ' 0 ',
' Pageurl ' text COMMENT ' note case Pageurl ',
' Insert_time ' timestamp not NULL DEFAULT current_timestamp COMMENT ' Add Time ',
' orderby_id ' int (one) not NULL DEFAULT ' 1 ' COMMENT ' sort ',
' Status ' tinyint (1) Not NULL DEFAULT ' 1 ' COMMENT ' state 0 is off, 1 is open ',
PRIMARY KEY (' id '),
KEY ' unique_id ' (' unique_id ') USING BTREE
) Engine=innodb auto_increment=2383 DEFAULT Charset=utf8 row_format=dynamic comment= ' Project table ';
If the unique index: unique KEY ' unique_id ' (' unique_id ') USING BTREE
You can also do this directly: (Unique index)
unique_id VARCHAR (255) Unique not NULL DEFAULT ' COMMENT ' project and data unique ID ',
Inquire:
Show index from Sj_projects; --Query all indexes of sj_projects
SHOW CREATE TABLE Sj_projects\g
To add an index:
ALTER TABLE ' sj_projects ' ADD UNIQUE ' unique_id ' (' unique_id '); --Unique index
ALTER TABLE ' sj_projects ' ADD INDEX ' unique_id ' (' unique_id '); --General Index
ALTER TABLE ' sj_projects ' ADD INDEX ' uniqueId ' (' unique_id '); --Normal index can modify the name
To delete an index:
ALTER TABLE ' sj_projects ' DROP INDEX ' unique_id ';
To delete the self-Increment ID index:
The automatic growth of the ID key needs to be canceled first:
ALTER TABLE ' sj_projects ' MODIFY ' id ' int (ten) not NULL COMMENT ' id ';
Execute again: ALTER TABLE ' sj_projects ' DROP PRIMARY KEY;
MySQL Build table index