eg  select * into new_table from table;一直报 缺少关键字   求高手帮忙    oracle 中  select into 是如何使用的?

解决方案 »

  1.   


    create new_table as select * from table;
    你的写法是 sql server 的
      

  2.   


    select * into new_table from table;
     new_table应该是表对象,定义了吗?
      

  3.   


    求教大侠  有关于oracle sql 的详细文档吗  类似于w3cshool中sql 部分的
      

  4.   

    ---在sql server可以这样写
    select * into new_table from table;
    ----在oracle中只能定义变量new_table
    select * into new_table from table
      

  5.   


    我写大侠给我的sql 直接报无效的ORACLE 命令
      

  6.   


    oracle官方网站里提供了帮助文档下载,或者在线搜索的,不过是全英文
      

  7.   


    SQL> create table new_emp as select * from emp;
     
    Table created
     
    SQL> 
    上面的命令少了一个 table 关键字
      

  8.   


    declare
        emp_rows        emp%rowtype;  -- 定义表的行类型
    begin
        select * into emp_rows from emp where empno = 7788;  -- 必须保证记录数只有一条
        dbms_output.put_line(emp_rows.empno || ',' || to_char(emp_rows.ename));
    end;
      

  9.   


    --只查询一条记录
    declare
      emp_rows        emp%rowtype;  -- 定义表的行类型
    begin
      select * into emp_rows from emp where empno = 7788;  -- 必须保证记录数只有一条
      dbms_output.put_line(emp_rows.empno || ',' || to_char(emp_rows.ename));
    end;--多条记录
    declare
      emp_rows        emp%rowtype;  -- 定义表的行类型
      cursor cur is select * from emp;
    begin
      open cur;
      loop
        fetch cur into emp_rows;
        exit when cur%notfound;
        dbms_output.put_line(emp_rows.empno || ',' || to_char(emp_rows.ename));
      end loop;
      close cur;
    end;
      

  10.   

    declare
    v_ename varchar2(50);
    begin
    select ename into v_ename from emp where empno=&no;
    dbms_output.put_line('你的用户名是:'||v_name);
    end;
      

  11.   

    在运行时,会有多种数据类型,不知道楼主是什么意思,如果把单行into到一个变量对象中,那就将这个变量用%rowtype,定义一下。如果要into到一个表的变量对象,,就定义一个表的对象变量。当然也可into到变量中,像varchar2. number啦。至于写法吧,请楼主去查一下帮助文档,我这里记不得的了。
      

  12.   

    create table new_table as select * from table;
    insert into new_table values select * from table;
      

  13.   


    tab table%ROWTYPE
    SELECT * INTO TAB FROM TABLE
      

  14.   

    在sql server里面该语句会创建一个新表! 在oracle里面select...into...是pl/sql的变量赋值语句!
      

  15.   

    看不你想干啥,如果是将查询结果集来生成一张表并插入数据。可以这样写
    create table new_table_name as select * from table_name;
      

  16.   

    create table1 as select * from table2;
      

  17.   

    两种用法:
    1.指定具体字段
    vs_col1 table1.col1%TYPE;
    vs_col2 table1.col2%TYPE;
    select col1, col2 into vs_col1, vs_col2 from table1 where rownum = 1; 
    dbms_output.put_line(vs_col1);
    dbms_output.put_line(vs_col2);
    2.全表字段
    table_type table1%ROWTYPE;
    select * into table_type from table1 where rownum = 1;
    dbms_output.put_line(table_type.col1);
    dbms_output.put_line(table_type.col2);
    *注意:用这种select .. into 的时候,要保证每次只有一条记录被选出
      

  18.   

    创建一个表:
    create table new_table as
    select * from table;
    查询字段赋值:
    select 某一字段 into str from table;
      

  19.   

    期待高手能解决哦!我也是遇到这样的问题,难道into不是赋值到一个新的表中吗(在oracle中)