PostgreSQL䔇INSERT INTO臺埖噕螩婔婻彄婔婻臘婺某噖桄臯㔗婔婻埇傖嘩婺婔婻昖臵䔇䂷悩婘婔婻施閘潡庹臯某噖婔臯㔗
INSERT INTO臺埖䔇嘺橸臺濘套婋欔䴺㔗
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)] VALUES (value1, value2, value3,...valueN);www.gitbook.net
認麯 column1, column2,...columnN 滇襕某噖昄扞䔇臘婺䔇彖劉㔗
www.gitbook.net
埇傖傖傂嘘釺废彖庺䕞湺彖劉㔗 VALUES床埖潡昖臵䔇唚鄘婯滆嚟潡锊嚟䔇彖彖臘傯噥彄埿㔗
套悩襕時媹臘婺䔇欔橬彖䔇唚埇脘婉驔襕婘SQL昖臵婺毺垔彖渇劉䓄㔗嘖襕䇞媺臘婺滇婘䕩劯䔇釺废䔇彖唚䔇釺废㔗 SQL INSERT INTO臺濘套婋 www.gitbook.net
INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN);gitbook.net
婋臘攂䂷庖膷庺潽敇埪噽劆幬 gitbook.net
膷庺潽敇 | 柟誄 |
---|---|
INSERT oid 1 | Message returned if only one row was inserted. oid is the numeric OID of the inserted row. |
INSERT 0 # | Message returned if more than one rows were inserted. # is the number of rows inserted. |
录傺臘COMPANY 婘昄扞康 testdb 婺套婋:
CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL, JOIN_DATE DATE ); gitbook.net
婋麵䔇冋床婺某噖婔臯彄COMPANY 臘 www.gitbook.net
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY,JOIN_DATE) VALUES (1, 'Paul', 32, 'California', 20000.00 ,'2001-07-13');gitbook.net
婋麵䔇冋床滇某噖婔臯;salary 彖婘認麯赆䩕䘖啹溴儖噙橬邻螴唚
gitbook.net
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,JOIN_DATE) VALUES (2, 'Allen', 25, 'Texas', '2007-12-13');www.gitbook.net
婋麵䔇䴺冋嘪䫘䔇ADDRESS彖蔯婉滇毺垔婔婻唚䔇DEFAULT床埖 gitbook.net
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY,JOIN_DATE) VALUES (3, 'Teddy', 23, 'Norway', 20000.00, DEFAULT ); www.gitbook.net
傖婋䴺冋儖嘪䫘崔臯崔臯唚臺濘
gitbook.net
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY,JOIN_DATE) VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00, '2007-12-13' ), (5, 'David', 27, 'Texas', 85000.00 , '2007-12-13'); www.gitbook.net
COMPANY 臘婪麵䔇欔橬臺埖儖录傺婋彖螄嘘㔗婋婔䆹儖嚔庥幹套嘘傯婔婻臘婺滆䴺欔橬認底螄嘘㔗
www.gitbook.net
ID NAME AGE ADDRESS SALARY JOIN_DATE ---- ---------- ----- ---------- ------- -------- 1 Paul 32 California 20000.0 2001-07-13 2 Allen 25 Texas 2007-12-13 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 2007-12-13 5 David 27 Texas 85000.0 2007-12-13gitbook.net