mysql alter 语句用法,添加、修改、删除字段等
http://www.blogjava.net/Alpha/archive/2007/07/23/131912.html
//主键549830479
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//增加一个新列549830479
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
例2:alter table msglogabstract add subcaption int(255) default 0;
//删除列549830479
alter table t2 drop column c;
//重命名列549830479
alter table t1 change a b integer;
//改变列的类型549830479
alter table t1 change b b bigint not null;
alter table infos change list list tinyint not null default '0';
//重命名表549830479
alter table t1 rename t2;
加索引549830479
mysql> alter table tablename change depno depno int(5) not null;
mysql> alter table tablename add index 索引名 (字段名1[,字段名2 …]);
mysql> alter table tablename add index emp_name (name);
加主关键字的索引549830479
mysql> alter table tablename add primary key(id);
加唯一限制条件的索引549830479
mysql> alter table tablename add unique emp_name2(cardnumber);
删除某个索引549830479
mysql>alter table tablename drop index emp_name;
修改表:549830479
增加字段:549830479
mysql> ALTER TABLE table_name ADD field_name field_type;
修改原字段名称及类型:549830479
mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;
删除字段:549830479
mysql> ALTER TABLE table_name DROP field_name;
相关文档:
windows下:
解决办法:
1.检查你的Mysql目录有没有给系统的System用户权限。
2.删除掉你的 %WINDOWS%/my.ini 文件。
3.检查你的 c:/my.cnf 文件配置是否正确。
修改%windir%\my.ini,增加
[mysqld]
#设置basedir指向mysql的安装路径
basedir=D:\Program\Tools\mysql
datadir=D:\Program\Tools\mysql\data& ......
1,Mysql插入二进制大对象出现异常,插入二进制出现异常,怎么解决com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
解决办法:url=url=+"?useUnicode=true& ......
下面先来看看例子:
table
id name
1 a
2 b
3 c
4 c
5 b
库结构大概这样,这只是一个简单的例子,实际情况会复杂得多。
比如我想用一条语句查询得到name不重复的所有数据,那就必须使用distinct去掉多余的重复记录 ......
mysql text 长度
文章分类:数据库
今天在做DB设计的时候在想用TEXT 是否能够满足将来的数据,能够出现装不下的情况。
后来查询了一下官方手册得到了一个答案。
一个BLOB或TEXT列,最大长度为65535(2^16-1)个字符。
MEDIUMBLOB
MEDIUMTEXT
一个BLOB或TEXT列,最大长度为16777215(2^24-1)个字符。
LONG ......
基础部分
一、MySQL 获得当前日期时间 函数
1.1 获得当前日期+时间(date + time)函数:now()
mysql> select now();
+---------------------+
| now() |
+----------------- ......