• MySQL数据库、表常用操作


    1、按条件查询表中数据:

    mysql> select user,host,password from user;
    

    2、按组合条件查询表中数据:

    mysql> select id, password, username, concat(first_name,' ',last_name)as full_name, email from MyTable;
    

    3、更新表中某条数据:

    mysql> update MyTable set password='pbkdf2_sha256$36000$' where id='2';
    

    4、更新tb1表中指定的值到tb2表(相同email值的passowrd项):

    UPDATE tb2,tb1 
    SET tb2.password=tb1.password 
    WHERE tb1.email=tb2.email;
    

    5、删除某个表的某条数据:

    mysql> delete from MyTable where id="2";
    

    6、从Table2中按条件查询数据插入到Table1中:

    mysql> insert into Table1 ( id, password, username, full_name, email ) select id, password, username, full_name, email from Table2;
    

    7、导出数据库中的某个表的数据:

    [root@175 bin]# mysqldump -uMyUser -pMyPassword --databases MyDatabase --tables MyTable > /usr/local/src/MyDatabase_MyTable.sql
    

    8、导入某个表的数据到数据库:

    [root@175 bin]# mysql -uMyUser -pMyPassword MyDatabase < /usr/local/src/MyDatabase_MyTable.sql
    

    9、导出数据库:

    [root@175 bin]# /usr/local/mysql/bin/mysqldump -uMyUser -p MyDatabase --default-character-set=utf8 > MyDatabase.sql
    

    10、导入数据库:

    [root@175 bin]# /usr/local/mysql/bin/mysql -uMyUser -p MyDatabase < MyDatabase.sql
    

    11、查看数据表占用空间:

    mysql> use information_schema;
    mysql> select table_name, table_rows,data_length+index_length from tables where table_schema = "zabbixdb";
    

    [THE END]

  • 相关阅读:
    ASP.NET异步处理
    C# TPL学习
    canvas 动画库 CreateJs 之 EaselJS(上篇)
    kafka消息的可靠性
    流式处理框架storm浅析(下篇)
    流式处理框架storm浅析(上篇)
    网易严选后台系统前端规范化解决方案
    Question | 移动端虚拟机注册等作弊行为的破解之道
    Puppeteer入门初探
    ThreeJs 3D 全景项目开发总结
  • 原文地址:https://www.cnblogs.com/configure/p/9210052.html
Copyright © 2020-2023  润新知