欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

HGDBPG表中添加删除列的方法

程序员文章站 2022-06-15 10:13:03
HGDB表中添加删除列: highgo=# \d test Table "public.test" Column | Type | Modifiers...

HGDB表中添加删除列:

highgo=# \d test

Table "public.test"

Column | Type | Modifiers

--------+---------+------------

id | integer | default 15

no | integer |

highgo=# select * from test;

id | no

----+----

15 | 1

15 | 2

15 |

(3 rows)

highgo=# alter table test add column name varchar(10);

ALTER TABLE

highgo=# select * from test;

id | no | name

----+----+------

15 | 1 |

15 | 2 |

15 | |

(3 rows)

highgo=# insert into test (no,name) values (1,'a');

INSERT 0 1

highgo=#

highgo=# select * from test;

id | no | name

----+----+------

15 | 1 |

15 | 2 |

15 | |

15 | 1 | a

(4 rows)

highgo=# alter table test drop column name;

ALTER TABLE

highgo=# select * from test;

id | no

----+----

15 | 1

15 | 2

15 |

15 | 1

(4 rows)