Blogger Information
Blog 40
fans 0
comment 0
visits 16016
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
MySQL的基本操作,表字段类型timestamp与datatime的区别.认识PDO
飞天001
Original
424 people have browsed it

实操MySQL DDL、DML、DCL

1. DDL

  1. //登陆
  2. mysql -u root -p //root为数据名
  3. //查询数据库
  4. show databases;(必须分号结束)
  5. //查询表
  6. show tables;

2. DCL

  1. //创建用户
  2. create user 'xxw'@localhost indentified by '123456'
  3. //给用户授权
  4. grant create,alter,drop,select on xxw.* to xxw@localhost;
  5. //查看权限
  6. show grants for xxw@localhost;
  7. //撤销权限
  8. revoke create on xxw.* from xxw@localhost;
  9. //删除用户
  10. drop user xxw@localhost;
  11. //修改密码
  12. alter user xxw@localhost identified by '123456';

3. DML

  1. //增
  2. INSERT `user` SET `name`='admin',`pwd`=`5445saswuq`;
  3. //删
  4. DELETE FROM `user` WHERE `id`=5
  5. //查
  6. SELECT `id`,`name` FROM `user`
  7. //改
  8. UPDATE `user` SET `name`='zhu' WHERE `id`=5;

字段类型timestamp与datatime的区别

  1. timestamp存储需要4个字节,它的取值范围为“1970-01-01 00:00:01 UTC ~ 2038-01-19 03:14:07 (和时区有关).
  2. timestamp取值显示的时候时间是根据时区来显示的.
  1. datetime存储需要8个字节,取值范围为“1000-01-01 00:00:00 ~ 9999-12-31 23:59:59”(和时区无关)

认识PDO

  1. //用pdo基类链接数据库
  2. $dsn = 'mysql:host=localhost;dbname=xxw';
  3. try {
  4. $db = new PDO($dsn, 'xxw', '123456');
  5. } catch (PDOException $e) {
  6. die('连接失败' . $e->getMessage());
  7. }
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post