zoukankan      html  css  js  c++  java
  • [转]MySQL select into,SQLServer select into

    以下的文章主要介绍的是MySQL select into 与 SQLServer select  into,我们大家都知道MySQL数据库是对Select Into 语句的直接备份表的结构与相关实际应用数据是不支持的,由于工作中的需要在网上找到一种方法可以代替, 也有其它方法可以处理,总结如下:

    方法1:

    MYSQL不支持:

    1. Select * Into new_table_name from old_table_name 

    替代方法:

    1. Create table new_table_name (Select * from old_table_name); 

    方法2:

    1.先备份表结构和数据

    导出命令 -u用户名 -p密码 -h主机IP地址 数据库名 表名1 > 导出文件.sql

    1. mysqldump -uroot -proot -h192.168.0.88 ok_db oktable2 > ok_db.sql 

    2.修改备份表的名字

    3.登录MySQL

    4.选择数据库

    5.执行: Source 备份表的路径 如:Source d:\ok_db.sql 回车即可。

    6.完成.

    SQLServer支持 MySQL Select into语句

    1.备份表直接执行如下就可以了。

    1. Select * Into new_table_name from old_table_name; 

    MySQL Select into outfile用于导出指定的查询数据到文件如下:

    1.导出表中所有数据到C盘根目录outfile.txt中如下:

    1. Select * into outfile 'c:\\outfile.txt' from test; 

    2.导出表中指定查询条件2005-06-08号的数据到C盘根目录outfile1.txt中如下:

    1. Select * into outfile 'c:\\outfile.txt' from test where beginDate='2008-06-08'
  • 相关阅读:
    网络系列之
    网络系列之
    Linux命令系列之
    Linux命令系列之
    Linux命令系列之
    Linux命令系列之
    Linux命令系列之
    Linux命令系列之
    Linux命令系列之
    Linux命令系列之
  • 原文地址:https://www.cnblogs.com/abinxm/p/2198422.html
Copyright © 2011-2022 走看看