易截截图软件、单文件、免安装、纯绿色、仅160KB

MySQL的datetime设置当前时间为默认值


MySQL的datetime设置当前时间为默认值 
由于MySQL目前字段的默认值不支持函数,所以用
create_time datetime default now()
的形式设置默认值是不可能的。
代替的方案是使用TIMESTAMP类型代替DATETIME类型。
CURRENT_TIMESTAMP :当我更新这条记录的时候,这条记录的这个字段不会改变

CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP :当我更新这条记录的时候,这条记录的这个字段将会改变
。即时间变为了更新时候的时间。(注意一个UPDATE设置一个列为它已经有的值,这将不引起TIMESTAMP列被更新,因为如果你设置一个列为它当前的值,MySQL为了效率而忽略更改。)如果有多个TIMESTAMP列,只有第一个自动更新。


相关文档:

php学习笔记(11):MYSQL在php5中的应用


1、php与mysql建立连接
php.ini 加载mysql组件
extension=php_mysql.dll前的;去掉
exetension_dir=""路径是否正确
Php连接mysql函数
mysql_connect:开启MYSQL连接
mysql_select_dir:打开一个数据库
@和or die 隐藏错误和条件显示
mysql_connect("主机","用户名","密码");  
mysql_sele ......

MYSQL中的 constraint 与 CONSTRAINT

一直习惯使用小写的SQL保留字,没想到今天居然遇到了麻烦哈!!和谐一下MYSQL啦!
环境:Server version: 5.1.37-1ubuntu5 (Ubuntu)
alter table child_table_name
add constraint constraint_name

foreign key (column_1)
references reference_table_name(reference_column_1);

ALTER  TABLE child_t ......

php学习笔记(12):PHP+MYSQL留言板(上

require()  与  require_once()
    
      通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require
所指定引入的文件,如果出现错误是致命的。
nclude()  与  include_once()
    
    &n ......

mysql 创建表并设置主键自增

mysql 创建表:
mysql> create table user(
    -> userid int(4) primary key not null auto_increment,
    -> username varchar(16) not null,
    -> userpassword varchar(32) not null
    -> );
create table log(
logid int(4) ......

mysql alter 语句用法,添加、修改、删除字段等


//主键
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//增加一个新列
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
//删除列
alter table t2 drop column c;
//重命名列
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号