|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
那时候Sybase已经诞生了6年的时间。至于其他值得关注的开源数据库,PostgreSQL将在2009年达到20岁的生日。虽然MySQL并不是市场上最年轻的数据库,但是却有更多成熟的数据库可供我们选择。这个自己属于MySQL的基础语法,我这里给出一个例子罢了。
viewplaincopytoclipboardPRint?
mysql>--测试数据库在指定地位增添字段
mysql>droptableifexistst;
QueryOK,0rowsaffected(0.06sec)
mysql>createtablet(ageint,addressvarchar(50));
QueryOK,0rowsaffected(0.06sec)
mysql>desct;
+---------+-------------+------+-----+---------+-------+
|Field|Type|Null|Key|Default|Extra|
+---------+-------------+------+-----+---------+-------+
|age|int(11)|YES||NULL||
|address|varchar(50)|YES||NULL||
+---------+-------------+------+-----+---------+-------+
2rowsinset(0.02sec)
mysql>altertabletaddcolumnnamevarchar(20)afterage;
QueryOK,0rowsaffected(0.16sec)
Records:0Duplicates:0Warnings:0
mysql>desct;
+---------+-------------+------+-----+---------+-------+
|Field|Type|Null|Key|Default|Extra|
+---------+-------------+------+-----+---------+-------+
|age|int(11)|YES||NULL||
|name|varchar(20)|YES||NULL||
|address|varchar(50)|YES||NULL||
+---------+-------------+------+-----+---------+-------+
3rowsinset(0.00sec)
mysql>altertabletaddcolumnidintFIRST;
QueryOK,0rowsaffected(0.13sec)
Records:0Duplicates:0Warnings:0
mysql>desct;
+---------+-------------+------+-----+---------+-------+
|Field|Type|Null|Key|Default|Extra|
+---------+-------------+------+-----+---------+-------+
|id|int(11)|YES||NULL||
|age|int(11)|YES||NULL||
|name|varchar(20)|YES||NULL||
|address|varchar(50)|YES||NULL||
+---------+-------------+------+-----+---------+-------+
4rowsinset(0.00sec)
mysql>
mysql>--测试数据库在指定地位增添字段
mysql>droptableifexistst;
QueryOK,0rowsaffected(0.06sec)
mysql>createtablet(ageint,addressvarchar(50));
QueryOK,0rowsaffected(0.06sec)
mysql>desct;
+---------+-------------+------+-----+---------+-------+
|Field|Type|Null|Key|Default|Extra|
+---------+-------------+------+-----+---------+-------+
|age|int(11)|YES||NULL||
|address|varchar(50)|YES||NULL||
+---------+-------------+------+-----+---------+-------+
2rowsinset(0.02sec)
mysql>altertabletaddcolumnnamevarchar(20)afterage;
QueryOK,0rowsaffected(0.16sec)
Records:0Duplicates:0Warnings:0
mysql>desct;
+---------+-------------+------+-----+---------+-------+
|Field|Type|Null|Key|Default|Extra|
+---------+-------------+------+-----+---------+-------+
|age|int(11)|YES||NULL||
|name|varchar(20)|YES||NULL||
|address|varchar(50)|YES||NULL||
+---------+-------------+------+-----+---------+-------+
3rowsinset(0.00sec)
mysql>altertabletaddcolumnidintFIRST;
QueryOK,0rowsaffected(0.13sec)
Records:0Duplicates:0Warnings:0
mysql>desct;
+---------+-------------+------+-----+---------+-------+
|Field|Type|Null|Key|Default|Extra|
+---------+-------------+------+-----+---------+-------+
|id|int(11)|YES||NULL||
|age|int(11)|YES||NULL||
|name|varchar(20)|YES||NULL||
|address|varchar(50)|YES||NULL||
+---------+-------------+------+-----+---------+-------+
4rowsinset(0.00sec)
mysql>
相干的语法形貌为
ALTER[ONLINE|OFFLINE][IGNORE]TABLEtbl_namealter_specification[,alter_specification]...alter_specification:table_option...|ADD[COLUMN]col_namecolumn_definition[FIRST|AFTERcol_name]
RDBMS并非没有局限性。它们难以扩展,需要大量的资源来配置和维护,比如时间、硬件和人力。同样,它们往往遵循峰值性能模型,这就要求系统按照峰值容量来配置可用性,而不考虑典型的数据使用情况。 |
|