create new_table as select * from table; 你的写法是 sql server 的
select * into new_table from table; new_table应该是表对象,定义了吗?
求教大侠 有关于oracle sql 的详细文档吗 类似于w3cshool中sql 部分的
---在sql server可以这样写 select * into new_table from table; ----在oracle中只能定义变量new_table select * into new_table from table
我写大侠给我的sql 直接报无效的ORACLE 命令
oracle官方网站里提供了帮助文档下载,或者在线搜索的,不过是全英文
SQL> create table new_emp as select * from emp;
Table created
SQL> 上面的命令少了一个 table 关键字
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; -- 定义表的行类型 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;
declare v_ename varchar2(50); begin select ename into v_ename from emp where empno=&no; dbms_output.put_line('你的用户名是:'||v_name); end;
create new_table as select * from table;
你的写法是 sql server 的
select * into new_table from table;
new_table应该是表对象,定义了吗?
求教大侠 有关于oracle sql 的详细文档吗 类似于w3cshool中sql 部分的
select * into new_table from table;
----在oracle中只能定义变量new_table
select * into new_table from table
我写大侠给我的sql 直接报无效的ORACLE 命令
oracle官方网站里提供了帮助文档下载,或者在线搜索的,不过是全英文
SQL> create table new_emp as select * from emp;
Table created
SQL>
上面的命令少了一个 table 关键字
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; -- 定义表的行类型
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;
v_ename varchar2(50);
begin
select ename into v_ename from emp where empno=&no;
dbms_output.put_line('你的用户名是:'||v_name);
end;
insert into new_table values select * from table;
tab table%ROWTYPE
SELECT * INTO TAB FROM TABLE
create table new_table_name as select * from table_name;
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 的时候,要保证每次只有一条记录被选出
create table new_table as
select * from table;
查询字段赋值:
select 某一字段 into str from table;