这么重要的一个GBase 8a 功能,竟然没给一个例子,通过alter change功能可以修改字段名字。
目录导航
参考
方法
rename 只能修改表名字,通过change功能,可以修改列名,已经增加varchar类型字段的长度,其它属性必须完整保留。
gbase> desc xgplace;
+-------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| name | varchar(100) | YES | | NULL | |
| ln | decimal(10,6) | YES | | NULL | |
| la | decimal(10,6) | YES | | NULL | |
| note | varchar(8000) | YES | | NULL | |
| region | varchar(20) | YES | | NULL | |
| dateadd | date | YES | | NULL | |
| street | varchar(100) | YES | | NULL | |
| date_inuput | date | YES | | NULL | |
+-------------+---------------+------+-----+---------+-------+
8 rows in set (Elapsed: 00:00:00.00)
gbase> alter table xgplace change date_inuput date_input date;
Query OK, 0 rows affected (Elapsed: 00:00:00.13)
Records: 0 Duplicates: 0 Warnings: 0
gbase> desc xgplace;
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| name | varchar(100) | YES | | NULL | |
| ln | decimal(10,6) | YES | | NULL | |
| la | decimal(10,6) | YES | | NULL | |
| note | varchar(8000) | YES | | NULL | |
| region | varchar(20) | YES | | NULL | |
| dateadd | date | YES | | NULL | |
| street | varchar(100) | YES | | NULL | |
| date_input | date | YES | | NULL | |
+------------+---------------+------+-----+---------+-------+
8 rows in set (Elapsed: 00:00:00.00)