1.创建表空间
CREATE TEMPORARY TABLESPACE IBASE4JTEMP
TEMPFILE ‘G:\app\hannasong\oradata\orcl\IBASE4JTEMP.DBF‘
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
CREATE TABLESPACE IBASE4J
LOGGING
DATAFILE ‘G:\app\hannasong\oradata\orcl\IBASE4J.DBF‘
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
create user sinosong identified by sinosong
default tablespace IBASE4J
temporary tablespace IBASE4JTEMP
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to sinosong;
grant resource to sinosong;
--grant connect,resource,dba to sinosong;
-- Grant/Revoke system privileges
grant create any sequence to sinosong;
grant create any view to sinosong;
grant create procedure to sinosong;
grant create table to sinosong;
grant create tablespace to sinosong;
grant create trigger to sinosong;
grant export full database to sinosong;
grant import full database to sinosong;
grant unlimited tablespace to sinosong;
drop user sinosong cascade;
select ‘alter table ‘||table_name||‘ allocate extent;‘ from user_tables where num_rows=0 or num_rows is null;
5.有数据的字段调整
如number-->String
create table BIZ_RENTAL_FACTORING_KEY_2 as select * from BIZ_RENTAL_FACTORING_KEY ;
drop table... create table...
insert into BIZ_RENTAL_FACTORING_KEY select * from BIZ_RENTAL_FACTORING_KEY_2;
若char-->varchar,
获取时不能写*,需要带trim()。
或者通过
sql执行:alter user sinosong account unlock
DELETE FROM table_name a WHERE rowid > ( SELECT min(rowid) FROM table_name b WHERE b.id = a.id and b.name=a.name);
1、查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断
select * from 表 where Id in (select Id from 表 group byId having count(Id) > 1)
2、删除表中多余的重复记录,重复记录是根据单个字段(Id)来判断,只留有rowid最小的记录
DELETE from 表 WHERE (id) IN ( SELECT id FROM 表 GROUP BY id HAVING COUNT(id) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM 表 GROUP BY id HAVING COUNT(*) > 1);
3、查找表中多余的重复记录(多个字段)
select * from 表 a where (a.Id,a.seq) in(select Id,seq from 表 group by Id,seq having count(*) > 1)
4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录
delete from 表 a where (a.Id,a.seq) in (select Id,seq having count(*) > 1) and rowid not in (select min(rowid) from 表 group by Id,seq having count(*)>1)
5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录
select * from 表 a where (a.Id,seq having count(*)>1)
1、误删数据
还原表
1.打开Flash存储的权限
ALTER TABLE tableName ENABLE row movement;
2.把表还原到指定时间点
flashback table tableName to timestamp to_timestamp(‘2018-01-01 00:00:00‘,‘yyyy-mm-dd hh24:mi:ss‘);--后面的参数为要还原的时间点
利用Oracle的快照进行查找某个时间点的数据,可以
查询到指定的时间段的数据
select * from tableName AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL ‘100‘ MINUTE)
或
select * from tableName as of timestamp to_timestamp(‘2018-01-01 00:00:00‘,‘yyyy-mm-dd hh24:mi:ss‘);
2、误删表
select * from user_recyclebin;
FLASHBACK TABLE TABLE_NAME TO BEFORE DROP;
如果是删了或
修改里面的数据,可以先建立一个快表将
删除修改之前状态的数据找回到这个表中:
CREATE TABLE QUICK_TABLE AS SELECT * FROM TABLE_NAME AS OF TIMESTAMP SYSDATE-1/24;(1/24一小时之前,5/1440为5分钟之前,或者指定日期(‘2018-01-01 00:00:00‘,‘yyyy-mm-dd hh24:mi:ss‘))
9.密码过期问题
alter user userXXX identified by xxx;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
误删恢复==》
https://blog.csdn.net/shiyu1157758655/article/details/79578009
http://www.blogjava.net/freeman1984/archive/2013/04/23/398
301.html