zoukankan      html  css  js  c++  java
  • SQL server查询语句

      作者:邓聪聪

      mysql部分语句的查询,持续更新                

    系统函数
    函数名 描述 举例
    convert() 数据类型转换 selece convert(varchar(5),12345) 返回:字符串12345
    cast() 数据类型转换,与convert相比其语法较简单,转换功能相对较少 select cast(‘2018-12-4’ as datetime) 返回:字符串2018-12-4 00:00:00.000
    current_user() 返回当前登陆的数据库用户名 select current_user 返回:当前登陆的数据库用户名
    datalength() 返回用于指定表达式的字节数 select datalength(‘中国 a 杭州’) 返回:9 注:一个中文代表2个字节
    host_name() 返回当前用户所登陆的计算机名称 select host_name() 返回:当前登陆的计算机名
    system_user() 返回当前登陆的系统用户名 select system_user 返回:当前登陆的系统用户名
    sysdate() 从当前数据库获取当前数据库的时间  select sysdate();返回:当前数据库的时间
    聚合函数
    函数 意义
    SUM() 总和
    AVG () 平均值
    MAX () 最高值
    MIN () 最低值
    COUNT() 统计字符

    事例:

      1.查询表中全部行数(COUNT)

      select count(*) as 总行数 from 表名

      2.查询表中的到期时间大于当前时间时间(curdate())

      select username,password,disable_time from user_pppoe where disable_time > curdate();

      3.创建用户(create)

      create user 'username'@'%' identified by '123456';

       4.授权给用户

      grant all  on dbname.* to 'username'@'%';   #允许远程连接

      grant all on *.* to username@localhost identified by "123456";  #允许本地连接

      5.删除数据库中,用户为空的localhost

      delete from user where user='' and host='localhost';

      6.查询事物锁

      elect * from information_schema.INNODB_LOCKS;

      7.锁表

      flush tables with read lock;         //解锁 unlock tables;

      

      

      

      

  • 相关阅读:
    C语言中for循环的使用
    详解C语言的main函数
    计算机语言的发展(the history of computer's language)
    hdu 1001
    hoj 1002
    hdu 1000
    POJ 1000(水题)
    hoj 1001
    code hunt题解(1)
    《C和指针》学习笔记(3)
  • 原文地址:https://www.cnblogs.com/dengcongcong/p/10576359.html
Copyright © 2011-2022 走看看