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'