MySQL表结构复制、表数据迁移以及临时表、视图创建

1、只拷贝表结构,不拷贝数据

select * into b from a where 1<>1;

 

2、表数据迁移

      表b已经存在:

insert into b (d, e, f) select a, b, c from a;

     表b原先不存在:

create table b (select a, b, c from a);

 

3、创建临时表

      创建临时表的语法很简单,临时表存在内存中,会话结束即消失:

create temporary table a (...);

 

4、创建视图

      视图属于数据库:

create view test.myView as select a, b from a;

 

注:文章转载至  http://www.cnblogs.com/feichexia/archive/2012/12/21/2827837.html


创建新表时,将结果集 插入到新表中

Create table new_table_name (Select * from old_table_name);
select * into new_table_name from old_table_name;


mysql 用户信息的创建及赋予权限

1.创建一个用户,用于远程登陆即数据操作
 create user 'webanker'@'%' identified by 'webanker'; 
2.赋予该用户一些操作权限,grant all on webanker 说明,赋予了用户操作该数据库下所有的所有操作权限
 grant all on webanker.* to 'webanker'@'%' identified by 'webanker' with grant option; 
注:有需要的话,在创建此用户的同时,应该创建一个相同的本地用户,即 'webanker'@'localhost'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值