Move sql scripts required by installers

This commit is contained in:
Carlos Ruiz 2013-04-02 22:45:38 -05:00
parent eb8146112b
commit f48984ef6e
23 changed files with 2 additions and 444 deletions

View File

@ -1,5 +0,0 @@
-- Connection Test
SELECT 'Success ' AS Connection FROM DUAL
/
EXIT

View File

@ -1,112 +0,0 @@
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: AfterImport.sql,v 1.2 2006/05/28 22:52:07 jjanke Exp $
***
* Title: After Import
* Description:
* - General Info
* - Create Context
* - Check Imported User and list ivalid objects
* You can ignore import warnings as long as this does not
* return error messages or records.
************************************************************************/
SELECT 'DB_Name=' || SYS_CONTEXT('USERENV', 'DB_NAME')
|| ', Language=' || SYS_CONTEXT('USERENV', 'LANGUAGE')
|| ', Host=' || SYS_CONTEXT('USERENV', 'HOST')
|| ', IP=' || SYS_CONTEXT('USERENV', 'IP_ADDRESS')
|| ', User=' || SYS_CONTEXT('USERENV', 'CURRENT_USER')
|| ', ID=' || SYS_CONTEXT('USERENV', 'CURRENT_USERID')
|| ', Session=' || SYS_CONTEXT('USERENV', 'SESSIONID')
AS "DBInfo"
FROM DUAL
/
SET serveroutput ON
-- Recompile invalids
BEGIN
DBA_Cleanup();
DBA_AfterImport;
-- DBA_Recompile(NULL); -- called in DBA_AfterImport
END;
/
-- Correct DataFile sizing
DECLARE
CURSOR Cur_TS IS
SELECT FILE_NAME, Tablespace_Name, Bytes/1024/1024 as MB
FROM DBA_DATA_FILES
WHERE (TABLESPACE_NAME='USERS' AND BYTES < 100*1024*1024)
OR (TABLESPACE_NAME='INDX' AND BYTES < 100*1024*1024)
OR (TABLESPACE_NAME='TEMP' AND BYTES < 100*1024*1024);
v_CMD VARCHAR2(300);
BEGIN
FOR ts IN Cur_TS LOOP
DBMS_OUTPUT.PUT_LINE('Resize:');
v_CMD := 'ALTER DATABASE DATAFILE ''' || ts.FILE_NAME
|| ''' RESIZE 100M';
DBMS_OUTPUT.PUT_LINE(' executing: ' || v_CMD);
EXECUTE IMMEDIATE v_CMD;
v_CMD := 'ALTER DATABASE DATAFILE ''' || ts.FILE_NAME
|| ''' AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED';
DBMS_OUTPUT.PUT_LINE(' executing: ' || v_CMD);
EXECUTE IMMEDIATE v_CMD;
END LOOP;
END;
/
/** Database Sizing
** Oracle 10g should use Automatic Shared Memory Management -
** Example 300MB
*
* ALTER SYSTEM documentation
http://download-east.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_2013.htm#SQLRF00902
*
SELECT Name, Value, Description, IsDefault FROM v$parameter
WHERE Name LIKE '%cursor%' OR Name LIKE '%process%' OR NAME LIKE '%servers%' ORDER BY 1
/
SELECT Name, Value/1024/1024 "MB", Description, IsDefault, Update_Comment FROM v$parameter
WHERE Name LIKE '%_pool_size' OR Name LIKE 'sga%'
/
ALTER SYSTEM SET statistics_level = TYPICAL Comment='Adempiere' SCOPE=BOTH
/
ALTER SYSTEM SET sga_target = 314572800 Comment='Adempiere' SCOPE=BOTH
/
ALTER SYSTEM SET open_cursors = 900 Comment='Adempiere' SCOPE=BOTH
/
/** Oracle 9i needs to set explicitly (and restart)
** Example 300MB
ALTER SYSTEM SET sga_max_size=314572800 SCOPE=SPFILE
/
ALTER SYSTEM SET large_pool_size=33554432 SCOPE=SPFILE
/
ALTER SYSTEM SET java_pool_size=67108864 SCOPE=SPFILE
/
/** SELECT 32*1024*1024 FROM DUAL **/
-- Any invalids
SELECT Object_Type "Type", Object_Name "Invalid", Status
FROM User_Objects
WHERE Status <> 'VALID'
/
-- Trigger Info
SELECT Trigger_Name AS Trigger_NotEnabled, Status
FROM User_Triggers
WHERE Status != 'ENABLED'
/
-- Constraint Info
SELECT Constraint_Name AS Constraint_Problem, Status, Validated, Table_Name, Search_Condition, R_Constraint_Name
FROM User_Constraints
WHERE Status <> 'ENABLED' OR Validated <> 'VALIDATED'
/
SELECT *
FROM USER_ERRORS
/
COMMIT
/
EXIT

View File

@ -1,94 +0,0 @@
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: BackupCold.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: Cold Backup
* Description:
* Generate OS cold Backup script
* Change the parameter variables p_ as required
* Run as system
************************************************************************/
SPOOL BackupCold.bat
DECLARE
p_backupLocation VARCHAR2(255) := 'D:\Backup';
p_unix BOOLEAN := FALSE;
p_useZip BOOLEAN := TRUE;
p_zipCmd VARCHAR(60) := 'wzzip ';
--
v_delimiter VARCHAR(10);
v_remark VARCHAR(10);
v_copy VARCHAR(60);
v_sid VARCHAR(30);
v_cmd VARCHAR2(2000);
--
CURSOR CUR_DataFiles IS
SELECT Name
FROM v$datafile;
CURSOR CUR_CtlFiles IS
SELECT Name
FROM v$controlfile;
BEGIN
-- OS Specifics
IF (p_unix) THEN
v_delimiter := '/';
v_remark := '# ';
v_copy := 'cp ';
ELSE
v_delimiter := '\';
v_remark := 'Rem ';
v_copy := 'copy ';
END IF;
--
SELECT Value
INTO v_sid
FROM v$parameter
WHERE Name ='instance_name';
p_backupLocation := p_backupLocation || v_delimiter || v_sid;
--
DBMS_OUTPUT.PUT_LINE(v_remark || 'Backup script for "' || v_sid || '" to ' || p_backupLocation);
DBMS_OUTPUT.PUT_LINE(v_remark || 'This script is automatically created by ColdBackup.sql and may need to be edited';
DBMS_OUTPUT.NEW_LINE;
--
DBMS_OUTPUT.PUT_LINE(v_remark || 'mkdir ' || p_backupLocation);
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.PUT_LINE('sqlplus "system/manager@%AccortoDBService% AS SYSDBA" @%AccortoHome%\util\orastop.sql');
DBMS_OUTPUT.NEW_LINE;
IF (p_useZip) THEN
DBMS_OUTPUT.PUT_LINE(p_zipCmd || p_backupLocation || v_delimiter || v_sid || '.zip ');
DBMS_OUTPUT.PUT(' ');
END IF;
FOR f IN CUR_DataFiles LOOP
IF (p_useZip) THEN
DBMS_OUTPUT.PUT(' ' || f.Name);
ELSE
DBMS_OUTPUT.PUT_LINE(v_copy || f.Name || ' ' || p_backupLocation);
END IF;
END LOOP;
IF (p_useZip) THEN
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.PUT(' ');
END IF;
FOR f IN CUR_CtlFiles LOOP
IF (p_useZip) THEN
DBMS_OUTPUT.PUT(' ' || f.Name);
ELSE
DBMS_OUTPUT.PUT_LINE(v_copy || f.Name || ' ' || p_backupLocation);
END IF;
END LOOP;
IF (p_useZip) THEN
DBMS_OUTPUT.NEW_LINE;
END IF;
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.PUT_LINE('sqlplus "system/manager@%AccortoDBService% AS SYSDBA" @%AccortoHome%\util\orastart.sql');
END;
/
SPOOL OFF
EXIT

View File

@ -1,21 +0,0 @@
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2002 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: BeforeExport.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: Before Export
* Description:
* - Delete Temporary Data
************************************************************************/
DELETE T_Report
/
DELETE T_Replenish
/
DELETE T_Spool
/
EXIT

View File

@ -1,93 +0,0 @@
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: CheckDB.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: TabeSpace Sizing
* Description:
* Make sure, that Tablespace
* USERS is 150 MB, 10 MB Autoextend
* INDX is 100 MB, 10 MB Autoextend
* TEMP is 100 MB, 10 MB Autoextend
* Set SGA Size (optional)
* Executed with System user and parameter %ADEMPIERE_DB_USER% from RUN_Env
************************************************************************/
-- Check existance
SELECT 'Tablespace USERS does not exist - You need to create it first' AS Missing FROM DUAL
WHERE NOT EXISTS (SELECT * FROM DBA_TABLESPACES WHERE TABLESPACE_NAME='USERS');
SELECT 'Tablespace INDX does not exist - You need to create it first' AS Missing FROM DUAL
WHERE NOT EXISTS (SELECT * FROM DBA_TABLESPACES WHERE TABLESPACE_NAME='INDX');
SELECT 'Tablespace TEMP does not exist - You need to create it first' AS Missing FROM DUAL
WHERE NOT EXISTS (SELECT * FROM DBA_TABLESPACES WHERE TABLESPACE_NAME='TEMP');
/*****
* Changing System Parameters
* directly - (e.g. 400 MB for 10 Users)
ALTER SYSTEM SET SGA_MAX_SIZE=400M COMMENT='400MB' SCOPE=SPFILE;
ALTER SYSTEM SET SHARED_POOL_SIZE=100M SCOPE=SPFILE;
ALTER SYSTEM SET DB_CACHE_SIZE=200M SCOPE=SPFILE;
ALTER SYSTEM SET JAVA_POOL_SIZE=40M SCOPE=SPFILE;
ALTER SYSTEM SET LARGE_POOL_SIZE=10M SCOPE=SPFILE;
** indirectly - sqlplus "system/manager@adempiere AS SYSDBA"
CREATE PFile='pfileAdempiere.ora' FROM SPFile;
* creates file in $ORACLE_HOME\database or $ORACLE_HOME/dbs
* edit file and then overwrite the fila via
CREATE SPFile FROM PFile='pfileAdempiere.ora';
*****/
-- Create System Record - OK, if it fails
-- Schema is parameter.
INSERT INTO &1..AD_System
(AD_System_ID,AD_Client_ID,AD_Org_ID,
IsActive,Created,CreatedBy,Updated,UpdatedBy,
Name, UserName, Info)
SELECT 0,0,0,'Y', SysDate,0,SysDate,0, '?','?','?'
FROM Dual
WHERE NOT EXISTS
(SELECT * FROM &1..AD_System WHERE AD_System_ID=0);
-- Add Info - OK, if fails
UPDATE &1..AD_System
SET Info = (SELECT SYS_CONTEXT('USERENV', 'DB_DOMAIN')
|| ',' || SYS_CONTEXT('USERENV', 'DB_NAME')
|| ',IP=' || SYS_CONTEXT('USERENV', 'IP_ADDRESS')
|| ',' || SYS_CONTEXT('USERENV', 'HOST')
|| ',' || SYS_CONTEXT('USERENV', 'INSTANCE')
|| ',UID=' || SYS_CONTEXT('USERENV', 'CURRENT_USER')
|| ',' || SYS_CONTEXT('USERENV', 'CURRENT_USERID')
|| ',C#=' || (SELECT COUNT(*) FROM &1..AD_Client)
FROM DUAL),
Updated=SysDate;
COMMIT;
set serveroutput on
-- Correct sizing
DECLARE
CURSOR Cur_TS IS
SELECT FILE_NAME, Tablespace_Name, Bytes/1024/1024 as MB
FROM DBA_DATA_FILES
WHERE (TABLESPACE_NAME='USERS' AND BYTES < 100*1024*1024)
OR (TABLESPACE_NAME='INDX' AND BYTES < 100*1024*1024)
OR (TABLESPACE_NAME='TEMP' AND BYTES < 100*1024*1024);
v_CMD VARCHAR2(300);
BEGIN
DBMS_OUTPUT.PUT_LINE('Resize:');
FOR ts IN Cur_TS LOOP
v_CMD := 'ALTER DATABASE DATAFILE ''' || ts.FILE_NAME
|| ''' RESIZE 100M';
DBMS_OUTPUT.PUT_LINE(' executing: ' || v_CMD);
EXECUTE IMMEDIATE v_CMD;
v_CMD := 'ALTER DATABASE DATAFILE ''' || ts.FILE_NAME
|| ''' AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED';
DBMS_OUTPUT.PUT_LINE(' executing: ' || v_CMD);
EXECUTE IMMEDIATE v_CMD;
END LOOP;
END;
/
EXIT

View File

@ -1,18 +0,0 @@
SET ECHO ON
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: CreateUser.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: Create or replace directory for data pump
* Description:
* Parameter: Directory
* Run as system
************************************************************************/
CREATE OR REPLACE DIRECTORY ADEMPIERE_DATA_PUMP_DIR AS '&1'
/
EXIT

View File

@ -1,36 +0,0 @@
SET ECHO ON
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: CreateUser.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: Drop User and re-create new
* Description:
* Parameter: UserID UserPwd
* Run as system
************************************************************************/
DROP USER &1 CASCADE
/
CREATE USER &1 IDENTIFIED BY &2
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK
/
GRANT CONNECT TO &1
/
GRANT DBA TO &1
/
GRANT RESOURCE TO &1
/
GRANT UNLIMITED TABLESPACE TO &1
/
ALTER USER &1 DEFAULT ROLE CONNECT, RESOURCE, DBA
/
GRANT CREATE TABLE TO &1
/
EXIT

View File

@ -1,23 +0,0 @@
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2002 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: Daily.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: Daily Tasks
* Description:
* - Recompile
* - Cleanup
************************************************************************/
DECLARE
Result VARCHAR2(2000);
BEGIN
DBA_Recompile(Result);
DBMS_OUTPUT.PUT_LINE(Result);
DBA_Cleanup();
END;
/
EXIT

View File

@ -1,18 +0,0 @@
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: Start.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: Start Database
* Description:
* Start the script via
* sqlplus "system/$ADEMPIERE_DB_SYSTEM AS SYSDBA" @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/Start.sql
************************************************************************/
set pause off
set echo on
startup
exit

View File

@ -1,19 +0,0 @@
/*************************************************************************
* The contents of this file are subject to the Adempiere License. You may
* obtain a copy of the License at http://www.adempiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Adempiere ERP+CRM
* Copyright (C) 1999-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: Stop.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
***
* Title: Stop Database and save configuration in trace
* Description:
* Start the script via
* sqlplus "system/$ADEMPIERE_DB_SYSTEM AS SYSDBA" @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/Stop.sql
************************************************************************/
set pause off
set echo on
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
shutdown transactional
exit

View File

@ -1,5 +0,0 @@
-- Connection Test
SELECT 'Success ' AS Connection FROM DUAL
/
EXIT

View File

@ -65,3 +65,5 @@ BEGIN
DBMS_OUTPUT.PUT_LINE ('End');
COMMIT;
END;
/