【数据库】-Oracle常用语法
2017-06-23 16:42
274 查看
1、备份数据
create table copy_tableas select *from tablewhere 条件
注意:当where条件成立时,会复制表结构+表数据;当where条件不成立,只会创建相同的表结构,不会复制表数据
2、清空表数据
delete from tablewhere 1=1
3、日期&时间
时间:to_date('2017/5/27 11:21:50','yyyy-mm-dd hh24:mi:ss')
日期:to_date('2017/5/27','yyyy-mm-dd')
4、存储过程
1)单表数据构造:
declare
i int:= 初始值;
begin
while(i<值) loop
insert into 表(字段集) values (赋值);
i:= i+1;
end loop;
commit;
end;
2)主从表数据构造:
declare
i int:= 初始值;
begin
while(i<值) loop
insert into 主表(主键,其他字段集...) values (i,其他属性值...);
insert into 从表(主键,外键,其他字段集...) values (i,i,其他属性值...);
i:= i+1;
end loop;
commit;
end;
create table copy_tableas select *from tablewhere 条件
注意:当where条件成立时,会复制表结构+表数据;当where条件不成立,只会创建相同的表结构,不会复制表数据
2、清空表数据
delete from tablewhere 1=1
3、日期&时间
时间:to_date('2017/5/27 11:21:50','yyyy-mm-dd hh24:mi:ss')
日期:to_date('2017/5/27','yyyy-mm-dd')
4、存储过程
1)单表数据构造:
declare
i int:= 初始值;
begin
while(i<值) loop
insert into 表(字段集) values (赋值);
i:= i+1;
end loop;
commit;
end;
2)主从表数据构造:
declare
i int:= 初始值;
begin
while(i<值) loop
insert into 主表(主键,其他字段集...) values (i,其他属性值...);
insert into 从表(主键,外键,其他字段集...) values (i,i,其他属性值...);
i:= i+1;
end loop;
commit;
end;
相关文章推荐
- oracle数据库常用语法
- oracle数据库常用的sql语法语句总结
- ORACLE数据库常用操作
- ORACLE 中常用的查看数据库的SQL
- ORACLE 常用的SQL语法和数据对象
- ORACLE 常用的SQL语法和数据对象
- ORACLE 常用的SQL语法和数据对象
- [Oracle管理] DBA常用数据库管理SQL (摘录整理)
- ORACLE常用的SQL语法和数据对象
- ORACLE 常用的SQL语法和数据对象
- ORACLE 常用的SQL语法和数据对象
- ORACLE 常用的SQL语法和数据对象
- ZT:ORACLE 中常用的查看数据库的SQL
- ORACLE 常用的SQL语法和数据对象 选择自 i_like_database 的 Blog
- ORACLE 常用的SQL语法和数据对象
- Java中数据库联接池常用(Oracle)
- ORACLE 常用的SQL语法和数据对象
- 常用的查看数据库的SQL Oracle经验技巧集
- [导入]ORACLE 常用的SQL语法和数据对象
- ORACLE 常用的SQL语法和数据对象