Chinaunix首页 | 论坛 | 博客
  • 博客访问: 106409
  • 博文数量: 54
  • 博客积分: 1548
  • 博客等级: 上尉
  • 技术积分: 620
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-06 00:37
文章分类

全部博文(54)

文章存档

2011年(1)

2010年(22)

2009年(31)

分类: Mysql/postgreSQL

2009-04-27 16:15:39

表的修饰词:
1. primary key  一个表只能有一个主键,放在修饰符之后(最后).唯一,不变 与not null|unique结合
   primary key(id) | (id,host) 记录之间的主键不能同时相同(重要)
2. auto_incrment  只用于修饰int ,一个表只能有一个,而且字段必须定义为键(primary key |unique),not null
3. unique  字段唯一
4. null | not null
   null     未加时 null
   not null 未加时,数字为0;
                   字符为' '空字符串
5. default 默认值在插入时,没加自动默认。
6. unsigned 保证正值,修饰int float double decimal
   zerofill 补零  
  
数据类型修饰:data(nmuber) : int(11) varchar(50)  decimal(5,2) datetime timestamp
1.日期和时间类型 : (可以或不带分隔符的整数序列)
                  date 描述为字符串 要加分隔符隔开 '2003-03-04'
                  time 描述为字符串 要加冒号隔开 '12:30:50'
2.datetime 当前时间 函数now()
  timestamp 当前时间 放空或者指定 null
             timestamp(nmuber)
3. enum set 值为在预先所设值,就会设为空,不是null
4. int(M) char|varchar(M) timestamp(M).decimal(M,N)
   如果tinyint smallint mediumint bigint 安装默认的字节
5. char 删除最后空格,varchar保留
6. enum ,set 重复数据,只保留一个
7. float double 浮点数
   decimal 定点数,字符串的形式存放,更准确.
8. date 4 time 3 year 1 datetime 8 timestamp 4
  
比较运算符 != = in(存在于指定集合)不同于= |>
           is null |is not null
逻辑运算符 and or not
显示记录的限制: limit 2 | limit 2,5 开始位置,显示个数
like 通配符 %全部 _单个 like '%e% |like '_e_'
全文搜索 alter table name add fulltext index (字段名);
         match (字段名) against ('匹配')|against ('+ - ' in boolean mode);
正则表达式 regexp '^ $ * ? + ' ^[^l] 句首|反 . a(m,n)
阅读(508) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~