Script for desc table_name
I have 198 tables in a schema.
I want to spool the output of describe table_name command.
need a script.
em reverse engineer the CREATE USER command for an user and associated privilges
rem
rem
rem works in 9i and higher
rem this code uses XML
rem
set long 10000000 heading off verify off pages 0 feedback off
set lines 132
column ddl format a132 word_wrap
define unam='&1'
-- make sure every statement is followed by a semicolon
execute dbms_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
spool &unam._tablespaces.sql
select dbms_metadata.get_ddl('TABLESPACE', tablespace_name) from dba_tablespaces;
spool off
spool &unam._defs.sql
-- get the create user statement
select dbms_metadata.get_ddl('USER',upper('&unam')) ddl from dual;
-- get his profile
select dbms_metadata.get_ddl('PROFILE', profile) ddl from dba_users where username=upper('&unam');
-- get his roles
select dbms_metadata.get_granted_ddl('ROLE_GRANT',upper('&unam')) ddl from dual;
-- get his enabled roles
select dbms_metadata.get_granted_ddl('DEFAULT_ROLE',upper('&unam')) ddl from dual;
-- get his system privileges
select dbms_metadata.get_granted_ddl('SYSTEM_GRANT',upper('&unam')) ddl from dual;
spool off
-- get his table definitions
spool &unam._defs.tab
select DBMS_METADATA.GET_DDL('TABLE',u.table_name,upper('&unam')) ddl
FROM DBA_ALL_TABLES u
WHERE u.nested='NO'
AND (u.iot_type is null or u.iot_type='IOT')
and owner=upper('&unam')
-- get his comments defintions. There are none, currently
select dbms_metadata.get_dependent_ddl('COMMENT',u.table_name, upper('&unam')) ddl
FROM DBA_ALL_TABLES u
WHERE u.nested='NO'
AND (u.iot_type is null or u.iot_type='IOT')
and owner=upper('&unam')
spool off
spool &unam._defs.idx
-- get his index definitions
select DBMS_METADATA.GET_DDL('INDEX',i.index_name,upper('&unam')) ddl
FROM DBA_INDEXES i
WHERE
owner=upper('&unam')
order by table_name, index_name
spool off
spool &unam._defs.prc
-- get his pl/sql
select dbms_metadata.get_ddl(o.object_type, o.object_name,upper('&unam')) ddl
from dba_objects O
where owner= upper('&unam')
AND OBJECT_TYPE in ('PROCEDURE','FUNCTION','PACKAGE','VIEW','TRIGGER')
-- get his object privileges
-- note
spool off
spool &unam._defs.prv
variable grn refcursor;
begin
open :grn for
'select dbms_metadata.get_dependent_ddl(''OBJECT_GRANT'', object_name, upper(''&unam'') )
from dba_objects
where owner=upper(''&unam'') and object_type != ''INDEX'' ' ;
exception
when others then null;
end;
print grn
spool off
exit
Use at own risk
Sybrand Bakker
Senior Oracle DBA
Similar Messages
-
Shell script for online table redefinition
Hi,
Could someone help me out in building a script for online table redefinition in AIX 11g, moving the table into a new table space.
ThanksYou are embarking upon a voyage in which you will expend a substantial effort reinventing the wheel.
Look at Oracle DBMS_REDEFINITION built-in package.
http://www.morganslibrary.org/reference/pkgs/dbms_redefinition.html
and never do something outside the database, in a proprietary language, that can be done far more efficiently inside the RDBMS in a platform independent language.
In other words, inside the database, I could code your entire project with error handling, in far less than an 15 minutes including testing.
With a simple DDL statement, issued at the command prompt in SQL*Plus ... I could do it in less than 15 seconds: Your choice.
ALTER TABLE <table_name> MOVE TABLESPACE <new_tablespace_name>; -
Script for Free Space in Datafiles
Hi
Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
1)Is dba_Free_Space an exact indicator of how much space is available in a file.
2) What is the significance of using blocks in vs using bytes.
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
Thanks in advance for you help.
Script for checking backwards for free space at end of file
REM Script is meant for Oracle version 9 and higher
REM -----------------------------------------------
set serveroutput on
exec dbms_output.enable(1000000);
declare
cursor c_dbfile is
select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
from dba_data_files f,
dba_tablespaces t
where f.tablespace_name = t.tablespace_name
and t.status = 'ONLINE'
order by f.tablespace_name,f.file_id;
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
/* variables to check settings/values */
dummy number;
checkval varchar2(10);
block_correction number;
/* running variable to show (possible) end-of-file */
file_min_block number;
/* variables to check if recycle_bin is on and if extent as checked is in ... */
recycle_bin boolean:=false;
extent_in_recycle_bin boolean;
/* exception handler needed for non-existing tables note:344940.1 */
sqlstr varchar2(100);
table_does_not_exist exception;
pragma exception_init(table_does_not_exist,-942);
begin
/* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
begin
select value into checkval from v$parameter where name = 'recyclebin';
if checkval = 'on'
then
recycle_bin := true;
end if;
exception
when no_data_found
then
recycle_bin := false;
end;
/* main loop */
for c_file in c_dbfile
loop
/* initialization of loop variables */
dummy :=0;
extent_in_recycle_bin := false;
file_min_block := c_file.blocks;
begin
<<check_free>>
for c_free in c_freespace(c_file.file_id)
loop
/* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
block_correction := (0-mod(c_free.max_block,2));
if file_min_block = c_free.max_block+block_correction
then
/* free extent is at end so file can be resized */
file_min_block := c_free.block_id;
else
/* no more free extent at end of file, file cannot be further resized */
exit check_free;
end if;
end loop;
end;
/* check if file can be resized, minimal size of file 16 blocks */
if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
then
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('cannot be resized no free extents found');
dbms_output.put_line('.');
else
/* file needs minimal no of blocks which does vary over versions */
if file_min_block < 16
then
file_min_block := 16;
end if;
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
/* below is only true if recyclebin is on */
if recycle_bin
then
begin
sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
execute immediate sqlstr into dummy;
if dummy > 0
then
dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
end if;
exception
when no_data_found
then null;
when table_does_not_exist
then null;
end;
end if;
dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
dbms_output.put_line('.');
end if;
end loop;
end;
Example output for Oracle version 9 and higher:
Tablespace: TEST Datafile: /oradata/v112/test01.dbf
cannot be resized no free extents found
Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
Tablespace: USERS Datafile: /oradata/v112/users01.dbf
current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
Extents found in recyclebin for above file/tablespace
Implying that purge of recyclebin might be needed in order to resize
SQL> purge tablespace USERS;
SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248KHi
Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
1)Is dba_Free_Space an exact indicator of how much space is available in a file.
2) What is the significance of using blocks in vs using bytes.
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
Thanks in advance for you help.
Script for checking backwards for free space at end of file
REM Script is meant for Oracle version 9 and higher
REM -----------------------------------------------
set serveroutput on
exec dbms_output.enable(1000000);
declare
cursor c_dbfile is
select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
from dba_data_files f,
dba_tablespaces t
where f.tablespace_name = t.tablespace_name
and t.status = 'ONLINE'
order by f.tablespace_name,f.file_id;
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
/* variables to check settings/values */
dummy number;
checkval varchar2(10);
block_correction number;
/* running variable to show (possible) end-of-file */
file_min_block number;
/* variables to check if recycle_bin is on and if extent as checked is in ... */
recycle_bin boolean:=false;
extent_in_recycle_bin boolean;
/* exception handler needed for non-existing tables note:344940.1 */
sqlstr varchar2(100);
table_does_not_exist exception;
pragma exception_init(table_does_not_exist,-942);
begin
/* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
begin
select value into checkval from v$parameter where name = 'recyclebin';
if checkval = 'on'
then
recycle_bin := true;
end if;
exception
when no_data_found
then
recycle_bin := false;
end;
/* main loop */
for c_file in c_dbfile
loop
/* initialization of loop variables */
dummy :=0;
extent_in_recycle_bin := false;
file_min_block := c_file.blocks;
begin
<<check_free>>
for c_free in c_freespace(c_file.file_id)
loop
/* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
block_correction := (0-mod(c_free.max_block,2));
if file_min_block = c_free.max_block+block_correction
then
/* free extent is at end so file can be resized */
file_min_block := c_free.block_id;
else
/* no more free extent at end of file, file cannot be further resized */
exit check_free;
end if;
end loop;
end;
/* check if file can be resized, minimal size of file 16 blocks */
if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
then
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('cannot be resized no free extents found');
dbms_output.put_line('.');
else
/* file needs minimal no of blocks which does vary over versions */
if file_min_block < 16
then
file_min_block := 16;
end if;
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
/* below is only true if recyclebin is on */
if recycle_bin
then
begin
sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
execute immediate sqlstr into dummy;
if dummy > 0
then
dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
end if;
exception
when no_data_found
then null;
when table_does_not_exist
then null;
end;
end if;
dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
dbms_output.put_line('.');
end if;
end loop;
end;
Example output for Oracle version 9 and higher:
Tablespace: TEST Datafile: /oradata/v112/test01.dbf
cannot be resized no free extents found
Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
Tablespace: USERS Datafile: /oradata/v112/users01.dbf
current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
Extents found in recyclebin for above file/tablespace
Implying that purge of recyclebin might be needed in order to resize
SQL> purge tablespace USERS;
SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248K -
My installation running on Windows 2000 Oracle9i. When issue desc table_name i get ORA-03113: end-of-file on communication channel. I have set processes = 300 in parameter file.
The ORA-03113: end-of-file on communication channel error is a generic error. The ORA-03113 error when connecting suggests that the connection was established, but lost later, like a timeout.
There are many possible causes for the ORA-03113 error. See MetaLink Note:17613.1 "ORA-03113":
For example, ORA-3113 could be signaled for any of these scenarios:
- Server machine crashed
- Your server process was killed at O/S level
- Network problems
- Oracle internal errors / aborts on the server
- Client incorrectly handling multiple connections
- etc.. etc.. etc.. - a lot of possible causes !!
It goes on to note that the ORA-03113 End-Of-File error often has additional messages:
It is common for this error to be accompanied by other errors such as:
- ORA-1041 internal error. hostdef extension doesn't exist
- ORA-3114 not connected to ORACLE
- ORA-1012 not logged on
To find more details, check for a trace file in your USER_DUMP_DEST and BACKGROUND_DMP_DEST directory.
Hope this helps . . .
Donald K. Burleson
Oracle Press author
Author of "Oracle Tuning: The Definitive Reference"
http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm -
How to find the existing sql server backup plan/schedule is there a script for that?
Friends,
Is there a easy way to find out in SQLServer (for All DB's) what is the current backup plan/schedule ? is there a script for that?
Thanks,
Karthikeyan JothiTo check the database backup
Select
SERVERPROPERTY('ServerName'),
db.name,
CONVERT(VARCHAR(10), b.backup_start_date, 103) + + convert(VARCHAR(8), b.backup_start_date, 14) backup_start_date,
CONVERT(VARCHAR(10), b.backup_finish_date, 103) + + convert(VARCHAR(8), b.backup_finish_date, 14) backup_finish_date,
case
when (DATEDIFF(hour, b.backup_start_date, getdate())<24)then 'Success'
when (DATEDIFF(hour, b.backup_start_date, getdate())>=24)then 'Failed'
end Status,
DATEDIFF(hh, b.backup_finish_date, GETDATE())BackupAgeInHours,
(b.backup_size/1024/1024/1024 )BackupSize,
case b.[type]
WHEN 'D' THEN 'Full'
WHEN 'I' THEN 'Differential'
WHEN 'L' THEN 'Transaction Log'
END Type,
ISNULL(STR(ABS(DATEDIFF(day, GetDate(),(Backup_finish_date)))), 'NEVER')DaysSinceLastBackup
FROM sys.sysdatabases db
Left OUTER JOIN (SELECT * , ROW_NUMBER() OVER(PARTITION BY database_name ORDER BY backup_finish_date DESC) AS RNUM
FROM msdb.dbo.backupset) b ON b.database_name = db.name AND RNUM = 1
where dbid<>2
OR
SELECT
DISTINCT
a.Name AS DatabaseName ,
CONVERT(SYSNAME, DATABASEPROPERTYEX(a.name, 'Recovery')) RecoveryModel ,
COALESCE(( SELECT CONVERT(VARCHAR(12), MAX(backup_finish_date), 101)
FROM msdb.dbo.backupset
WHERE database_name = a.name
AND type = 'd'
AND is_copy_only = '0'
), 'No Full') AS 'Full' ,
COALESCE(( SELECT CONVERT(VARCHAR(12), MAX(backup_finish_date), 101)
FROM msdb.dbo.backupset
WHERE database_name = a.name
AND type = 'i'
AND is_copy_only = '0'
), 'No Diff') AS 'Diff' ,
COALESCE(( SELECT CONVERT(VARCHAR(20), MAX(backup_finish_date), 120)
FROM msdb.dbo.backupset
WHERE database_name = a.name
AND type = 'l'
), 'No Log') AS 'LastLog' ,
COALESCE(( SELECT CONVERT(VARCHAR(20), backup_finish_date, 120)
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY backup_finish_date DESC ) AS 'rownum' ,
backup_finish_date
FROM msdb.dbo.backupset
WHERE database_name = a.name
AND type = 'l'
) withrownum
WHERE rownum = 2
), 'No Log') AS 'LastLog2'
FROM sys.databases a
LEFT OUTER JOIN msdb.dbo.backupset b ON b.database_name = a.name
WHERE a.name <> 'tempdb'
AND a.state_desc = 'online'
GROUP BY a.Name ,
a.compatibility_level
ORDER BY a.name
To check the schedule you can try the below script
https://gallery.technet.microsoft.com/SQL-Jobs-Complete-eabe0050
--Prashanth -
Desc table_name statements no longer running in sql developer
simple desc statements like desc table_name; used to run in sql developer however they no longer work.
It was working a few days ago and now the same statements dont return any results. The tables exist as I can run select statements fine just not desc table_name;
Any ideas how this can be fixed?I haven't had problems with the "desc table_name;" functionality for a long time - do you know of anything that has changed since they were working a few days ago?
If you run the following query with :1 being the table owner and :2 being the table name, do you get the columns listed?SELECT t.column_name "Name",
DECODE(t.nullable,'Y',NULL,'NOT NULL') "Null",
UPPER(t.data_type)
||
CASE
WHEN ( t.data_type = 'VARCHAR' OR t.data_type = 'VARCHAR2' OR t.data_type = 'RAW' OR t.data_type = 'CHAR' )
AND ( t.data_length != 0 AND NVL(t.data_length,-1) != -1)
THEN
CASE
WHEN(t.char_used = 'C' AND 'BYTE' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
THEN '(' || t.char_length || ' CHAR)'
WHEN(t.char_used = 'B' AND 'CHAR' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
THEN '(' || t.data_length || ' BYTE)'
WHEN(t.char_used = 'C' AND 'CHAR' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
THEN '(' || t.char_length || ')'
WHEN(t.char_used = 'B' AND 'BYTE' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
THEN '(' || t.data_length || ')'
ELSE '(' || t.data_length || ' BYTE)'
END
WHEN (t.data_type = 'NVARCHAR2' OR t.data_type = 'NCHAR')
THEN '(' || t.data_length/2 || ')'
WHEN (t.data_type LIKE 'TIMESTAMP%' OR t.data_type LIKE 'INTERVAL DAY%' OR t.data_type LIKE 'INTERVAL YEAR%' OR t.data_type = 'DATE' OR(t.data_type = 'NUMBER' AND (t.data_precision = 0 OR NVL(t.data_precision,-1) = -1)))
THEN ''
WHEN (t.data_scale = 0 OR NVL(t.data_scale,-1) = -1)
THEN '(' || t.data_precision ||')'
ELSE '(' || t.data_precision ||',' ||t.data_scale ||')'
END "Type"
FROM sys.all_tab_columns t,
sys.all_col_comments c
WHERE t.column_name = c.column_name
AND c.owner = t.owner
AND c.table_name = t.table_name
AND UPPER(t.owner) = UPPER(:1)
AND t.table_name = :2
ORDER BY t.column_idtheFurryOne -
How do i get a script for a table
hai
i need sql query to create table script for already existing table.
can any body help me.
Edited by: 800324 on Feb 24, 2011 12:07 AMfor examle
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
FROM USER_ALL_TABLES uEdited by: Mahir M. Quluzade on Feb 24, 2011 12:23 PM -
Generate script for filling table
Hi all,
I've got table at test Oracle server table1 with columns ID, BTYPE, MYDESCRIPTION. Rows of this table have been inserted manually. Now my need is to write script for creating table (structure + data). I think about writing something like
CREATE TABLE table 1
AS
SELECT 1 AS ID, 'TYPE1' AS BTYPE, 'SOME TEXT' AS MYDESCRIPTION
UNION ALL
SELECT 2 AS ID, 'TYPE2' AS BTYPE, 'SOME TEXT 2' AS MYDESCRIPTION
But rows are too many to type... Could you please suggest some way of generating script for creating table at working server using existing table at test server? The problem is I don't have an access to working server.
Thanks ahead.Use the view user_tab_cols
say
declare
cursor c1 is
select 'e_'||column_name ||' '||data_type||' ('||data_length||') ' col
from user_tab_cols
where table_name = 'DEPARTMENTS'
union
select 'd_'||column_name ||' '||data_type||' ('||data_length||') ' col
from user_tab_cols
where table_name = 'EMPLOYEES';
v1 varchar2(500);
begin
v1 := 'create table new_tabl (';
for i in c1 loop
v1 := v1||i.col||',';
end loop;
v1 := substr(v1,1,length(v1)-1);
dbms_output.put_line(v1||')');
end;
/i am using employees and departments table of hr schema.
now as both the tables have some column column so i have used e for employees and d for departments
just do one thing remove the length for date data type in o/p i dont know why it is not working.
this will give you structure for data use any sql stmt
Edited by: 810345 on Jun 9, 2011 9:58 PM -
Generating Insert Scripts for multiple tables
Hi,
I have 6 tables TABLA,TABLB,TABLC,TABLED,TABLEE,TABLEF
I want to generate Insert Scripts for the above 6 tables.
Is there any mechanism to do so so that i can generate the .sql files for the above 6 tables to another schema?
Any help will be needful for me.Hi,
May the below given function script help you...
CREATE OR REPLACE FUNCTION get_insert_script (v_table_name VARCHAR2)
RETURN VARCHAR2
AS
b_found BOOLEAN := FALSE;
v_tempa VARCHAR2 (8000);
v_tempb VARCHAR2 (8000);
v_tempc VARCHAR2 (255);
BEGIN
FOR tab_rec IN (SELECT table_name
FROM all_tables
WHERE table_name = UPPER (v_table_name))
LOOP
b_found := TRUE;
v_tempa := 'select ''insert into ' || tab_rec.table_name || ' (';
FOR col_rec IN (SELECT *
FROM cols
WHERE table_name = tab_rec.table_name
ORDER BY column_id)
LOOP
IF col_rec.column_id = 1
THEN
v_tempa := v_tempa || '''||chr(10)||''';
ELSE
v_tempa := v_tempa || ',''||chr(10)||''';
v_tempb := v_tempb || ',''||chr(10)||''';
END IF;
v_tempa := v_tempa || col_rec.column_name;
IF INSTR (col_rec.data_type, 'CHAR') > 0
THEN
v_tempc := '''''''''||' || col_rec.column_name || '||''''''''';
ELSIF INSTR (col_rec.data_type, 'DATE') > 0
THEN
v_tempc :=
'''to_date(''''''||to_char('
|| col_rec.column_name
|| ',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
ELSE
v_tempc := col_rec.column_name;
END IF;
v_tempb :=
v_tempb
|| '''||decode('
|| col_rec.column_name
|| ',Null,''Null'','
|| v_tempc
|| ')||''';
END LOOP;
v_tempa :=
v_tempa
|| ') values ('
|| v_tempb
|| ');'' from '
|| tab_rec.table_name
|| ';';
END LOOP;
IF NOT b_found
THEN
v_tempa := '- Table ' || v_table_name || ' not found';
ELSE
v_tempa := v_tempa || CHR (10) || 'select ''- commit;'' from dual;';
END IF;
RETURN v_tempa;
END;(copied and pasted from a commercial site)
*009*
Edited by: 009 on Jan 14, 2010 10:43 PM
(Function after debug) -
Genrating script for following scripts.
HI,
i have to genrate script for getting this output from 100 servers.
but i tried on 2 servers but out put was not prpaerly allinged i spool the output
can any one suggest me to take this output on CSV or other proper format.
1.1 select * from v$version
1.2 select * from v_$database
1.3 select * from sys.V_$PARAMETER
2.1 select * from sys.dba_users order by username
2.2 select * from sys.dba_profiles order by profile
3.1 select * from sys.dba_role_privs order by grantee
3.2 select table_name, privilege from dba_tab_privs where grantee = 'first_role_name' minus select table_name,privilege from dba_tab_privs where grantee = 'second_role_name'
3.3 select * from sys.dba_sys_privs order by grantee
3.4 select grantee from sys.dba_sys_privs where grantee IN (select username from sys.dba_users)
3.5 select grantee from sys.dba_sys_privs where grantee NOT IN (select granted_role from sys.dba_role_privs) AND grantee NOT IN (select username from sys.dba_users)
3.6 select grantee, table_name, privilege, grantable from sys.dba_tab_privs order by grantee
3.7 select grantee from sys.dba_tab_privs where grantee IN (select username from sys.dba_users)
3.8 select grantee from sys.dba_tab_privs where grantee NOT IN (select granted_role from sys.dba_role_privs) AND grantee NOT IN (select username from sys.dba_users)
3.9 select table_name, column_name, privilege from sys.dba_col_privs order by grantee
3.10 select grantee from sys.dba_col_privs where grantee IN (select username from sys.dba_users)
3.11 select grantee from sys.dba_col_privs where grantee NOT IN (select granted_role from sys.dba_role_privs) AND grantee NOT IN (select username from sys.dba_users)
4.1 select * from sys.V_$DATAFILE
4.2 select * from sys.V_$CONTROLFILE
5.1 select * from sys.product_user_profile order by username
6.1 select * from sys.dba_db_links This command lists database links
7.2 select * from sys.dba_stmt_audit_opts
7.3 select * from sys.dba_priv_audit_opts
thanks!!!Try with the SQL formating.... col format, linesize,wrap on off... etc...
See more here :
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch6.htm -
We've lost our backup script for a particularly hairy EXTERNAL TABLE def'n. TOAD is botching the script. Is there a SQL statement I can execute against the db which will deliver back the script?
-ChuckCharles,
<br>You can use DBMS_METADATA package.</br>
1 SELECT dbms_metadata.get_ddl('TABLE', table_name)
2 from user_tables
3* where table_name = 'EXT_RN_DEPLOY_DATA' --your table name
SQL> /
CREATE TABLE "SCOTT"."EXT_RN_DEPLOY_DATA"
( "MONITOR_ID" VARCHAR2(30),
"SAMPLE_ID" VARCHAR2(30),
"LATITUDE" VARCHAR2(10),
"DEW_POINT" NUMBER(18,8)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "DATA_FILE_DIR2"
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE SKIP 1
BADFILE DATA_FILE_DIR2:'REVEXT%A_%P.BAD'
LOGFILE DATA_FILE_DIR2:'REVEXT%A_%P.LOG'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
MISSING FIELD VALUES ARE NULL
LOCATION
( "DATA_FILE_DIR2":'load.csv'
REJECT LIMIT UNLIMITED
SQL> <br>More info <a href=http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch15.htm#1005930><b>here</b></a></br>
<br>Nicolas.</br> -
Creating SQL-Loader script for more than one table at a time
Hi,
I am using OMWB 2.0.2.0.0 with Oracle 8.1.7 and Sybase 11.9.
It looks like I can create SQL-Loader scripts for all the tables
or for one table at a time. If I want to create SQL-Loader
scripts for 5-6 tables, I have to either create script for all
the tables and then delete the unwanted tables or create the
scripts for one table at a time and then merge them.
Is there a simple way to create migration scripts for more than
one but not all tables at a time?
Thanks,
Prashant RaneNo there is no multi-select for creating SQL-Loader scripts.
You can either create them separately or create them all and
then discard the one you do not need. -
error while executing script for sharepoint online (office 365) - the remote server returned an error: (503) server unavailable.
I am creating many site collections reading records from sharepoint list using powershell in sharepoint online tenant (office 365).
Few site collections are created and then getting above error so this error record will be skipped then few succeeding record processed then again getting error.
pattern is like:
success
success
success
success
Error
success
success
success
success
success
success
error
successHi,
As it is an online environment, to troubleshoot this issue in an easier way, I suggest you contact Office 365 Support to see if there is any useful information in
the log files in the server side:
https://support.office.com/en-us/article/Contact-Office-365-for-business-support-32a17ca7-6fa0-4870-8a8d-e25ba4ccfd4b?ui=en-US&rs=en-US&ad=US
Best regards
Patrick Liang
TechNet Community Support -
Custom calculation script for checkboxs
Hello,
Can anyone help me out with custom calculation script for this? I have two mutually exclusive checkboxes that, when checked, I want to populate data into other text fields.
If Checkbox1 is checked:
Company1=Warehouse Alpha
Address1=1234 Any Street
City/State/Zip1= Los Angeles, CA 90020
Contact Name1= Mr. Nice Guy
Phone Number1= 213-854-8565
Email1=[email protected]
If Checkbox2 is checked:
Company2=Warehouse Beta
Address2= 5678 Awesome Blvd.
City/State/Zip2= San Bernardino, CA 96545
Contact Name2= Mr. Handsome
Phone Number2= 909-824-8265
Email2=[email protected]
Thanks,
BryanSo one has two check boxes and one wants them to be mutually exclusive. Name them the same and change the export value of the field. Try it and observe what happens as you check the different check boxes.
You have described what happens if either box is checked but what happens when a checked box Is unckecked?
One can place scripts in many locations. I would use a mouse up action for both the check boxes, use the same script for both check boxes.
I would assume you are using the following names for the fields to populate:
Company
Address
CityStateZip
ContactName
PhoneNumber
Email
// Mouse up action for both check boxes;
// initial value for the fields:
this.getField("Company"),value = "";
this.getField("CityStateZip"),value = "";
this.getField("ContactName"),value = "";
this.getField("PhoneNumber"),value = "";
this.getField("Email"),value = "";
// test for check box value for selected box;
if(event.value == 1) {
this.getField("Company"),value = "Warehouse Alpha";
this.getField("CityStateZip"),value = "1234 Any Street";
this.getField("ContactName"),value = "Los Angeles, CA 90020";
this.getField("PhoneNumber"),value = "213-854-8565";
this.getField("Email"),value = "[email protected]";
if(event.value == 2) {
this.getField("Company"),value = "Warehouse Beta";
this.getField("CityStateZip"),value = "5678 Awesome Blvd.";
this.getField("ContactName"),value = "San Bernardino, CA 96545";
this.getField("PhoneNumber"),value = "Mr. Handsome";
this.getField("Email"),value = "[email protected]";
// end Mouse up action for both check boxes; -
Sharepoint warmup script for https sites
we want to warm up https site which is based on sharepoint 2010.
When we run some sample powershells it shows access forbidden error so we are not able to warm up https site.
Its slow on first load so need some warmup script for https sites.
sharepointerJust ensure that the service account that you use to trigger the Powershell scripts has access to IIS and SharePoint. Most often, the SharePoint Farm account would be used for scheduling the warm up scripts on the WFE server.
I trust that answers your question...
Thanks
C
http://www.cjvandyk.com/blog
Maybe you are looking for
-
How do i update the software on an ipad provided by the company without syncing to my itunes?
I have an iPad2 provided by my employer based out of Arizona. I want to update the software to the most current available. I do not have access to the iTunes account used to set up the device, and if I use my iTunes, I will loose the apps and data in
-
fields in yvtrans r vendor ,name, country. buttons r : display , exit. first go to screen painter :se 51 give pgm : screen no: desc: save click layout goto->secondary window->dic->pgm fields table lfa1 select fields lifnr ,land1 , name1 enter drop
-
In the system preferences sharing where you go to set "Computer name" I am noticing that mine says "iMac (3)" I have changed it back but keeps renaming the name "iMac (1),iMac (2), iMac (3) and so on,,, ". My network hasn't changed, haven't added
-
Hi, I have a rather straightforward mapping (but it has over 20 source tables into the Joiner and out to one target table). I am getting the following 6 warnings when I deploy: ORA-06550: PACKAGE BODY, line 126, column 36:PL/SQL: ORA-00936: missing e
-
How to shrink my Call log screen?
By accident I've zoomed in my call log screen at max. Having zoomed in that much as a result of which I only can read a part of the screen/information (last 2 calls). How to shrink it again and have the overview back again? Thanks im advance, Daniel