insert into table (col) select [col] from select into outfile select [col] into var 等语句区别

insert   into table (col)  select [col] from

从 一个表中读取数据插入到另外一个表(也可以是本表)

1
insert  into tablename (col1,col2) select col1,col2 from tablename2 where  col1=2

select into outfile

1
select * from ffx_share into outfile '/tmp/a.sql'

一般情况下这个语句是执行不了的,因为涉及到 配置选项 secure_file_priv 默认是 null 就是无法执行,且不能通过set secure_file_priv=”目录” 来设置

必须在 [mysqld] 节点 或者 启动的时候 用 mysqld –secure_file_priv=/tmp 来启动

select [col] into var

把查询的字段值 赋值给变量

1
select col1,col2 into var1,var2  from tablename where col1=1;

未经允许不得转载:开心乐窝-乐在其中 » insert into table (col) select [col] from select into outfile select [col] into var 等语句区别

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏