zoukankan      html  css  js  c++  java
  • 通过现有数据导出新表SQL

    Date: 20140217

    Auth: JIN

    需求: 导出一个表的两个列的表的SQL语句(包含数据)

    方法:创立一个临时表

    mysql> desc kw_keywords;
    +------------+------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +------------+------------------+------+-----+---------+----------------+
    | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
    | keyword | varchar(100) | YES | MUL | | |
    | cat_id | int(1) unsigned | YES | | NULL | |
    | search_num | int(10) unsigned | YES | | NULL | |
    | priority | int(10) unsigned | YES | | NULL | |
    | is_embody | int(1) | YES | | NULL | |
    | url | varchar(256) | YES | | | |
    | remark | varchar(100) | YES | | | |
    | type | int(11) | YES | | NULL | |
    | addtime | datetime | YES | | NULL | |
    | updatetime | datetime | YES | | NULL | |
    +------------+------------------+------+-----+---------+----------------+
    11 rows in set (0.00 sec

    确认数据需要的数据
    select keyword,url from kw_keywords where remark='人工筛选';

    创建指定列的表
    create table tb_word select keyword,url from kw_keywords where remark='人工筛选';

    create table tb_word select keyword as word,url from kw_keywords where date_format(addtime,'%Y-%m-%d') in ('2014-02-25', '2014-02-28');

    确认
    mysql> select * from tb_word limit 10;

    导出
    # mysqldump -S /data/mysql/3310/mysql.sock -ppwd keyword tb_word > tb_word_20140217.sql

  • 相关阅读:
    近期学习(3)
    近期学习(1)
    近期学习(2)
    今日练习
    《明朝那些事儿》
    记一次针对恶意攻击者的渗透测试
    Kali Linux使用问题记录
    MySQL floor()报错原理
    使用复合设计模式扩展持久化的CURD,Select能力
    c#/js代码命名规范及代码规范
  • 原文地址:https://www.cnblogs.com/diege/p/3552616.html
Copyright © 2011-2022 走看看