查看MYSQL Tips的源代码
←
MYSQL Tips
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== 增、减表字段 == alter table YOUR_DB_NAME.TABLE_NAME add column NEW_COL int(10) DEFAULT NULL; //增加一个字段,默认为空 <source lang=bash> mysql> desc action; +-----------+------------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+------------------+------+-----+-------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | timestamp | timestamp | NO | | CURRENT_TIMESTAMP | | | action | text | NO | | NULL | | | processed | int(8) unsigned | NO | | 0 | | +-----------+------------------+------+-----+-------------------+----------------+ 4 rows in set (0.00 sec) mysql> alter table cos.action add column `nid` int(10) unsigned default null; Query OK, 20 rows affected (0.03 sec) Records: 20 Duplicates: 0 Warnings: 0 mysql> desc action; +-----------+------------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+------------------+------+-----+-------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | timestamp | timestamp | NO | | CURRENT_TIMESTAMP | | | action | text | NO | | NULL | | | processed | int(8) unsigned | NO | | 0 | | | nid | int(10) unsigned | YES | | NULL | | +-----------+------------------+------+-----+-------------------+----------------+ 5 rows in set (0.01 sec) mysql> alter table cos.action drop column nid; Query OK, 20 rows affected (0.02 sec) Records: 20 Duplicates: 0 Warnings: 0 mysql> desc action; +-----------+------------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+------------------+------+-----+-------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | timestamp | timestamp | NO | | CURRENT_TIMESTAMP | | | action | text | NO | | NULL | | | processed | int(8) unsigned | NO | | 0 | | +-----------+------------------+------+-----+-------------------+----------------+ 4 rows in set (0.00 sec) </source> <br><br>
返回到
MYSQL Tips
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面