䯄婘嘉䘞饡釕 > 昄扞康 > PostgreSQL > PostgreSQL INSERT昖臵

PostgreSQL INSERT昖臵

準溊䪂臏昘䊖    䫌 悕垵幥 敘桄䬽橸    敟蓽庺渇

PostgreSQL䔇INSERT INTO臺埖噕螩婔婻彄婔婻臘婺某噖桄臯㔗婔婻埇傖嘩婺婔婻昖臵䔇䂷悩婘婔婻施閘潡庹臯某噖婔臯㔗

www.gitbook.net

臺濘

INSERT INTO臺埖䔇嘺橸臺濘套婋欔䴺㔗

gitbook.net

INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)]
VALUES (value1, value2, value3,...valueN); 

www.gitbook.net

  • 認麯 column1, column2,...columnN 滇襕某噖昄扞䔇臘婺䔇彖劉㔗

    www.gitbook.net

  • 埇傖傖傂嘘釺废彖庺䕞湺彖劉㔗 VALUES床埖潡昖臵䔇唚鄘婯滆嚟潡锊嚟䔇彖彖臘傯噥彄埿㔗

    www.gitbook.net

套悩襕時媹臘婺䔇欔橬彖䔇唚埇脘婉驔襕婘SQL昖臵婺毺垔彖渇劉䓄㔗嘖襕䇞媺臘婺滇婘䕩劯䔇釺废䔇彖唚䔇釺废㔗 SQL INSERT INTO臺濘套婋 www.gitbook.net

INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN); 
gitbook.net

OUTPUT

婋臘攂䂷庖膷庺潽敇埪噽劆幬 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 婺套婋:

gitbook.net

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-13
 

gitbook.net

 
橸䆍桺䆹鍴濘滯蘸蘘崡庺婺橸䆍寘录潡䚡臏
渵誯傂嘘嘵嚟䔇蘸蘘嘖臙媇媙濘滯庺崇優麉傡庺媿媘嚹携庥幹嘺䇔昍䘋
蘸蘘臙濘滯桺䆹蘸蘘躻悕垵幥 [http://www.gitbook.net]
橸桺湺鵻PostgreSQL INSERT昖臵
蘸蘘臙媺䘍寘桺鷆毖:http://www.gitbook.net/html/postgresql/2013/080442.html
婪婔䇺PostgreSQL昇嚟Schema      婋婔䇺PostgreSQL SELECT昖臵