MYSQL创建有自增列的表

MYSQL创建有自增列的表

USE school;



CREATE TABLE cdat

(

   localt               CHAR(20) NOT NULL,

   cd                   CHAR(5) NOT NULL,

   snosat               CHAR(2) NOT NULL,

   rnorec               CHAR(3) NOT NULL,

   id                   INT(20) NOT NULL AUTO_INCREMENT,

   PRIMARY KEY (id)

);



INSERT INTO cdat(localt,cd,snosat,rnorec)

SELECT 'cc','ccc','ccd','sddf' UNION ALL

SELECT 'aaa','aaa','a','b' ;





SELECT LAST_INSERT_ID('');



SELECT * FROM cdat;

 

你可能感兴趣的:(mysql)