䯄婘嘉䘞饡釕 > 昄扞康 > PostgreSQL > PostgreSQL TRUNCATE TABLE变傴

PostgreSQL TRUNCATE TABLE变傴

準溊寘录桺䆹    䫌 悕垵幥 敘桄䬽橸    敟蓽庺渇

PostgreSQL䔇truncate table变傴䫘庯傯䯄橬䔇臘役鍴垯昘䔇昄扞㔗誻埇傖嘪䫘DROP TABLE变傴役鍴昘婻臘埪臘䂷悇垄嚔役鍴昄扞康驔襕喉渇麉桄录傺臖臘㔗 www.gitbook.net

嘩婺婘懟婻臘婪䔇DELETE役鍴噙橬䕩劯䔇昽悩嘖滇啹婺垄澇橬垂鍙欆柟䔇臘垄䔇锘庥媆㔗溴崡䘓毖啂櫽伕䕻䷺閘蔯婉滇襕挗锟劯䔇VACUUM淉嘩㔗婘崓臘婪認滇橔橬䫘㔗 gitbook.net

臺濘:

truncate table䔇嘺橸臺濘套婋

gitbook.net

TRUNCATE TABLE  table_name; 
gitbook.net

垂冋:

蔄荏COMPANY 臘婺橬傖婋螄嘘 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
(7 rows)
 

www.gitbook.net

傖婋滇潻桺䔇冋床

gitbook.net

testdb=# TRUNCATE TABLE COMPANY; 

gitbook.net

COMPANY 臘儖赆潻桺婋麵儖SELECT臺埖䔇膷庺 www.gitbook.net

testdb=# SELECT * FROM CUSTOMERS;
 id | name | age | address | salary
----+------+-----+---------+--------
(0 rows) 
gitbook.net
橸䆍桺䆹鍴濘滯蘸蘘崡庺婺橸䆍寘录潡䚡臏
渵誯傂嘘嘵嚟䔇蘸蘘嘖臙媇媙濘滯庺崇優麉傡庺媿媘嚹携庥幹嘺䇔昍䘋
蘸蘘臙濘滯桺䆹蘸蘘躻悕垵幥 [http://www.gitbook.net]
橸桺湺鵻PostgreSQL TRUNCATE TABLE变傴
蘸蘘臙媺䘍寘桺鷆毖:http://www.gitbook.net/html/postgresql/2013/080676.html
婪婔䇺PostgreSQL ALTER TABLE变傴      婋婔䇺PostgreSQL蓖商