varchar mysql,Mysql的varchar类型

Mysql的varchar类型

自从认识mysql的那天起就知道varchar的长度限制为255,不过现在这种情况已经改变了:

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.

In contrast to CHAR, VARCHAR values are stored as a one-byte or two-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.

...

The following table illustrates the differences between CHAR and VARCHAR by showing the result of storing various string values into CHAR(4) and VARCHAR(4) columns (assuming that the column uses a single-byte character set such as latin1).

Value

CHAR(4)

Storage Required

VARCHAR(4)

Storage Required

''

'    '

4 bytes

''

1 byte

'ab'

'ab  '

4 bytes

'ab'

3 bytes

'abcd'

'abcd'

4 bytes

'abcd'

5 bytes

'abcdefgh'

'abcd'

4 bytes

'abcd'

5 bytes

(http://dev.mysql.com/doc/refman/5.1/en/char.html)

以后基本可以不使用text字段了。。。。。。

相关文档:

C API相关

C API数据类型

MYSQL

该结构代表1个数据库连接的句柄。几乎所有的MySQL函数均使用它。不应尝试拷贝MYSQL结构。不保证这类拷贝结果会有用。

MYSQL_RES

该结构代表返回行的查询结果(SELECT, SHOW, DESCRIBE, EXPLAIN)。在本节的剩余部分,将查询返回的信息称为“结果集&rdq ......

update :单表的更新不用说了,两者一样,主要说说多表的更新

Oracle> Oracle的多表更新要求比较严格,所以有的时候不是很好写,我们可以试试Oracle的游标

&n ......

MySQL的备份方式,目前我想到的有五种,有可能还有

1,mysqldump方式,加上具体参数名(单库,多库,触发器,存储过程,表结构,字符集,–single-transaction,等等)

2,mysqlhotcopy 只能备份myisam数据表备份,速度相当快,因为是文件拷贝,可能瞬间被锁表,任何的数据操作,比如插入和更新都会挂起。

3,LVM� ......

* mysql首先将拿到的数据转换为character_set_client指定的编码格式,然后转换为 character_set_connection指定的格式,最后再将数据存储到数据库,存储格式为character_set_database所指定的格式;

* 从数据库读数据时,将数据库格式转换为character_set_results指定的格式,再发� ......

## **********first test,procedure**********

#<1>

use testprocedure;

delimiter //

create procedure simpleproce1 (out par1 int)

begin

select count(*) into par1 from proce;

end

//

delimiter ;

call simpleproce1(@a);

select @a;

#<2>,每次只有单一的行可以被取回select id,name i ......

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值