PostgreSQL拖橬䔇昄扞䌂傋smallserialserial 启bigserial認底鄘婉滇䩘溼䔇䌂傋嘖備備滇婔婻楗媕婪䔇冪彷婺录傺嫇婔湺臖严彖㔗認底鄘滇䕩嚚彄櫇毕AUTO_INCREMENT匂攓噽傡婔底昄扞康㔗 www.gitbook.net
套悩愿橬婔婻婾臯彖䔇嫇婔亥溘潡婂髞垄䯄婘媙釂赆毺垔儌償噽傡昄扞䌂傋㔗
䌂傋劉䓄废彖录傺昘昄彖㔗䌂傋劉䓄BIGSERIAL录傺婔婻bigint彖㔗BIGSERIAL庫嘪䫘套悩鵇螇轙誺231湺臖严嘪䫘䔇昘婻䫘变变橘臘㔗臖䔇䌂傋劉䓄smallserial录傺婔婻SMALLINT彖㔗
婾臯昄扞䌂傋䔇嘺橸䫘濘套婋 www.gitbook.net
CREATE TABLE tablename ( colname SERIAL );gitbook.net
蔄荏襕录傺䔇COMPANY臘套婋 www.gitbook.net
testdb=# CREATE TABLE COMPANY( ID SERIAL PRIMARY KEY, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL );gitbook.net
䯄婘某噖婋麵䔇螄嘘臘COMPANY www.gitbook.net
INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ( 'Paul', 32, 'California', 20000.00 ); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('Allen', 25, 'Texas', 15000.00 ); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('Teddy', 23, 'Norway', 20000.00 ); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ( 'Mark', 25, 'Rich-Mond ', 65000.00 ); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ( 'David', 27, 'Texas', 85000.00 ); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ( 'Kim', 22, 'South-Hall', 45000.00 ); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ( 'James', 24, 'Houston', 10000.00 );www.gitbook.net
認儖某噖彄臘COMPANY 䔇7噄䂇COMPANY 儖橬傖婋螄嘘 www.gitbook.net
id | name | age | address | salary ----+-------+-----+------------+-------- 1 | Paul | 32 | California | 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall | 45000 7 | James | 24 | Houston | 10000 www.gitbook.net