zoukankan      html  css  js  c++  java
  • mysql高级

    代码:

     1 # 创建视图
     2 # create view 视图名称 as select语句;
     3 create view v_goods_info as select g.*,c.name as cate_name,b.name as brand_name from goods as g left join goods_cates as c on g.cate_id=c.id left join goods_brands as b on g.brand_id=b.id;
     4 
     5 # 删除视图
     6 # drop view 视图名称;
     7 drop view v_goods_info;
     8 
     9 
    10 # 事务处理
    11 # 开启 begin;  或者 start transaction;
    12 begin;  # 第一种方法
    13 # start transaction;  # 第二种方法
    14 
    15 要完成的增删改
    16 
    17 # 成功 提交
    18 commit;
    19 # 失败 回滚
    20 rollback;
    21 
    22 # 创建索引
    23 create index 索引名称 on 表名(字段名称(长度))
    24 # 删除索引
    25 drop index 索引名称 on 表名;
    26 
    27 # 查询执行语句所用时间
    28     # 开启运行时间监测:
    29     set profiling = 1;
    30 
    31     执行语句。。。。。
    32 
    33     # 查看执行时间
    34     show profiles;
    35 
    36 # mysql账户管理
    37     # 创建账户&授权
    38         # 常用权限主要包括:create、alter、drop、insert、update、delete、select
    39         # 如果分配所有权限,可以使用all privileges
    40         # 可以操作python数据库的所有表,方式为:jing_dong.*
    41         # 访问主机通常使用 百分号% 表示此账户可以使用任何ip的主机登录访问此数据库
    42         # 访问主机可以设置成 localhost或具体的ip,表示只允许本机或特定主机访问
    43         # grant 权限列表 on 数据库 to '用户名'@'访问主机' identified by '密码';
    44         grant select on jing_dong.* to 'laowang'@'localhost' identified by '123456';
    45         grant all privileges on jing_dong.* to "laoli"@"%" identified by "12345678"
    46 
    47     # 查看用户有哪些权限
    48       show grants for laowang@localhost;
    49 
    50     # 修改权限
    51       # grant 权限名称 on 数据库 to 账户@主机 with grant option;
    52       # 修改密码
    53       # update user set authentication_string=password('新密码') where user='用户名';
    54       update user set authentication_string=password('123') where user='laowang';
    55       # 注意修改完成后需要刷新权限
    56       flush privileges
     1 # mysql账户管理
     2     # 删除账户
     3         # 语法1:终端使用root登录
     4         # drop user '用户名'@'主机';
     5         drop user 'laowang'@'%';
     6 
     7         # 语法2:删除mysql数据库的user表中的数据
     8         # delete from user where user='用户名';
     9         delete from user where user='laowang';
    10 
    11     # 删除以后一样要刷新权限
    12         flush privileges;
  • 相关阅读:
    转 W P 代码淆混
    Flash网页游戏辅助工具制作简析
    Flash Player安全沙漏规则
    用loader.loadbytes直接load bitmapdata.getpixels产生的bytearray
    游戏及开发人员的认识
    一犯人在执行死刑前三天供出祖传治癌奇方(转)
    AIR教程列表
    养生名言 (春、夏、秋、冬。)
    十天学会单片机和C语言编程
    UI设计规范收藏
  • 原文地址:https://www.cnblogs.com/yifengs/p/11454512.html
Copyright © 2011-2022 走看看