Header image  
mas databases  
line decor
  HOME :: BUSINESS :: COMPUTING :: LIFESTYLE :: PASTIME ::SCIENCES ::
line decor
   
 mas databases
 
       

Database Management Systems II


Structured Query Language ( tutorial: http://www.w3schools.com/sql/default.asp)


Elmasri/Navathe (3rd. ed.)

Kroenke Book (7th ed.)

McFadden (5th ed.)

Chapter 8

Chapter 9

Chapter 9

Structured Query Language

1.      Data Definition Language (DDL) Used to create (define) data structures such as tables, indexes, clusters

2.      Data Manipulation Language (DML) is used to store, retrieve and update data from tables.

SQL Data Types

Numeric Data Types

Character Strings

Date and Time

Comparing Data Types

 

Character

Number

Date

BLOB

MS Access

TEXT

NUMBER

DATE

MEMO or OLE OBJECT

Oracle

VARCHAR2

NUMBER or INTEGER

DATE

LONG or LONG RAW

Sybase

char

float or int

date

blob

IBM DB2

VARCHAR

DECIMAL or SMALLINT

DATE

BLOB, CLOB or DBLOB

MS SQL Server 7

VARCHAR or TEXT

DECIMAL, REAL or INT

DATETIME

image

Many commercial databases now have provisions for User Defined Types (UDTs).

Data Definition Language

Creating Domains

Note that Oracle, MS Access and MS SQL Server do not support creating domains.

Creating a Schema

Note: To try out these SQL examples in MS Access, go to the Queries form and choose New, then choose Design View and then close the next dialog box. Under the View menu, choose SQL. From this point, you can type in any SQL statemnt and execute it (click on the Exclamation point icon). Note that MS Access's DDL syntax is extremely limited. Most of the DDL statments below (including domains, NOT NULL constraints and referential integrity constraints) are not supported.

·                CREATE TABLE employee (
·                    Last_Name      d_last_name  NOT NULL,
·                    First_name     VARCHAR(18)  NOT NULL,
·                    Soc_Sec        d_soc_sec    NOT NULL,
·                    Date_of_Birth  DATE,
·                    Salary         d_salary
·                ) ;  
·                 
·                CREATE TABLE dependant (
·                    Last_Name        d_last_name  NOT NULL,
·                    First_name       VARCHAR(18)  NOT NULL,
·                    Soc_Sec          d_soc_sec    NOT NULL,
·                    Date_of_Birth    DATE,
·                    Employee_Soc_Sec d_soc_sec NOT NULL
·                );
·                 
·                CREATE TABLE order_header (
·                   order_number    NUMBER(10,0) NOT NULL,
·                   order_date      DATE,
·                   sales_person    VARCHAR(25),
·                   bill_to         VARCHAR(35),
·                   bill_to_address VARCHAR(45),
·                   bill_to_city    VARCHAR(20),
·                   bill_to_state   VARCHAR(2),
·                   bill_to_zip     VARCHAR(10),
·                   PRIMARY KEY (order_number)
·                );
·                 
·                CREATE TABLE order_items (
·                   order_number     NUMBER(10,0) NOT NULL,
·                   line_item        NUMBER(4,0)  NOT NULL,
·                   part_number      VARCHAR(12)  NOT NULL,
·                   quantity         NUMBER(4,0),
·                   PRIMARY KEY (order_number, line_item),
·                   FORIEGN KEY (order_number)
·                      REFERENCES order_header (order_number),
·                   FOREIGN KEY (part_number)
·                      REFERENCES parts (part_number)
·                );
·                 
·                CREATE INDEX order_index
·                    ON order_header (order_number) ASC ;
·                 
·                CREATE INDEX items_index
·                    ON order_items (order_number, line_item) ASC ;
·                 
·                 
·                Example from MS Access:
·                CREATE TABLE employee (
·                   FirstName TEXT, 
·                   LastName  TEXT, 
·                   ssn       INTEGER 
·                     CONSTRAINT ssnConstraint PRIMARY KEY
·                );
·                 
·                CREATE INDEX employee_index
·                 ON employee (ssn) ;
·                 

Specifying Constraints on Columns and Tables

·                CREATE TABLE order_items (
·                   order_number     NUMBER(10,0) NOT NULL,
·                   line_item        NUMBER(4,0)  NOT NULL,
·                   part_number      VARCHAR(12)  NOT NULL,
·                   quantity         NUMBER(4,0),
·                   PRIMARY KEY (order_number, line_item),
·                   FORIEGN KEY (order_number) 
·                      REFERENCES order_header (order_number)
·                      ON DELETE SET DEFAULT 
·                      ON UPDATE CASCADE,
·                   FOREIGN KEY (part_number)
·                      REFERENCES parts (part_number)
·                );
·                CREATE TABLE order_header (
·                   order_number    NUMBER(10,0) NOT NULL,
·                   order_date      DATE,
·                   sales_person    VARCHAR(25),
·                   bill_to         VARCHAR(35),
·                   bill_to_address VARCHAR(45),
·                   bill_to_city    VARCHAR(20),
·                   bill_to_state   VARCHAR(2),
·                   bill_to_zip     VARCHAR(10),
·                   CONSTRAINT order_header_pk
·                      PRIMARY KEY (order_number)
·                );
·                 
·                CREATE TABLE order_items (
·                   order_number     NUMBER(10,0) NOT NULL,
·                   line_item        NUMBER(4,0)  NOT NULL,
·                   part_number      VARCHAR(12)  NOT NULL,
·                   quantity         NUMBER(4,0),
·                 
·                   CONSTRAINT order_items_pk
·                       PRIMARY KEY (order_number, line_item),
·                 
·                   CONSTRAINT order_items_fk1
·                      FORIEGN KEY (order_number)
·                         REFERENCES order_header (order_number)
·                         ON DELETE SET DEFAULT 
·                         ON UPDATE CASCADE,
·                 
·                   CONSTRAINT order_items_fk2
·                      FOREIGN KEY (part_number)
·                         REFERENCES parts (part_number)
·                         ON DELETE SET DEFAULT 
·                         ON UPDATE CASCADE
·                );

Note that once you have successfully issued a CREATE TABLE statement, the table definition is created in your schema. If you issue a similar CREATE TABLE statement with the same table name, you will get an error that "...the table already exists." In this case, you would need to first DROP TABLE, then create it again.

In Oracle SQL*Plus, to see the tables you have created in your schema, issue the following query:
SELECT * FROM TAB;

Removing Schema Components with DROP

Changing Schema Components with ALTER

Note that in Oracle, you can not drop a column from a table using SQL commands. You must copy the table to a temporary table (minus the unwanted column), drop the original table and then copy the temporary table back to the original name.


Data Manipulation Language

Inserting Data into Tables

·                INSERT INTO tablename (column1, column2, ... columnX)
·                       VALUES (val1, val2, ... valX);
·                 
·                INSERT INTO employee (first_name, last_name, street, city, state, zip)
·                       VALUES ("Buddy", "Rich", "123 Sticks Ln.", "Fillville", "TN", "31212");
·                 
·                INSERT INTO stocks (symbol, close_date, close_price)
·                       VALUES ("IBM", "03-JUN-94", 104.25);
·                 
·                INSERT INTO student_grades (student_id, test_name, score, grade)
·                       VALUES (101, "Quiz 1", 88, "B+");

 

RDBMS

Text Data Type

Dates

MS Access

TEXT: Either " or '

DATETIME: Either " or '

Oracle

VARCHAR: '

DATE: '

IBM DB2

'

DATE: '

Sybase

CHAR and VARCHAR: "

DATE: "

Retrieving Data from Tables with Select

·                SELECT   column1, column2, ... columnN
·                FROM     tableA, tableB, ... tableZ
·                WHERE    condition1, condition2, ...conditionM
·                GROUP BY column1, ...
·                HAVING   condition
·                ORDER BY column1, column2, ... columnN

Assume an employees table:
employees(emplyee_id, first_name, last_name, street, city, state, zip)

Some example queries:

SELECT   employee_id, last_name, first_name
FROM     employees
WHERE    last_name = "Smith"
ORDER BY first_name DESC
 
 
SELECT   employee_id, last_name, first_name
FROM     employees
WHERE    salary > 40000
ORDER BY last_name, first_name DESC
 
SELECT   *
FROM     employees
ORDER BY 2;
 
SELECT   symbol, close_price
FROM     stocks
WHERE    close_date > "01-JAN-95" AND
         symbol = "IBM"
ORDER BY close_date
 
 
SELECT    symbol, close_date, close_price
FROM      stocks
WHERE     close_date >= "01-JAN-95"
ORDER BY  symbol, close_date

Relational Operators and SQL

·                        SELECT employee_id, last_name, first_name
·                        FROM   employee
·                        WHERE  salary > 40000 
·                        SELECT AVG(salary)
·                        FROM   employee
·                        WHERE  state = 'NJ'
·                        SELECT *
·                        FROM   employee
·                        WHERE  last_name = 'Smith' AND state = 'NY'

SQL Built-in Functions

Example Table GRADES:

Name    Major       Grade
Bill    CIS         95
Mary    CIS         98
Sue     Marketing   88
Tom     Finance     92
Alex    CIS         79
Sam     Marketing   89
Jane    Finance     83
...

Note: To try out these examples, create the table in MS Access and enter the data shown above. Go to the Queries form and choose New, then choose Design View and then close the next dialog box. Under the View menu, choose SQL.

·                  SELECT AVG(grade)
·                  FROM   students;
·                 
·                Results:
·                AVG(GRADE)
·                ----------
·                89.1428571
·                SELECT name, grade 
·                FROM   students
·                WHERE  grade = 
·                  (  SELECT MAX(grade) FROM students
·                  );
·                 
·                 
·                Results:
·                 
·                NAME           GRADE
·                -------------- -----
·                Mary           98
·                 
·                SELECT    name, major, grade
·                FROM      students s1
·                WHERE     grade = 
·                   (
·                     SELECT max(grade) 
·                     FROM   students s2 
·                     WHERE  s1.major = s2.major
·                   )
·                ORDER BY grade DESC;
·                 
·                 
·                Results:
·                 
·                NAME          MAJOR                GRADE
·                ------------- -------------------- -----
·                Mary          CIS                  98
·                Tom           Finance              92
·                Sam           Marketing            89

Note the two aliases given to the students table: s1 and s2. These allow us to refer to different views of the same table.

Selecting from 2 or More Tables

·                Example table EMPLOYEE:
·                Name     Department    Salary
·                Joe      Finance       50000
·                Alice    Finance       52000
·                Jill     MIS           48000
·                Jack     MIS           32000
·                Fred     Accounting    33000
·                 
·                 
·                Example table DEPARTMENTS:
·                Department      Location
·                Finance         NJ
·                MIS             CA
·                Accounting      CA
·                Marketing       NY
·                SELECT  employee.name
·                FROM    employee, department
·                WHERE   employee.department = department.department
·                AND     department.location = 'CA';
·                 
·                Results:
·                NAME
·                --------------------------------
·                Jill
·                Jack
·                Fred
·                SELECT    employee.name, department.location
·                FROM      employee, department
·                WHERE     employee.department = department.department
·                ORDER BY  department.location, employee.name;
·                 
·                Results:
·                NAME             LOCATION
·                ---------------  -------------
·                Fred             CA
·                Jack             CA
·                Jill             CA
·                Alice            NJ
·                Joe              NJ

This is similar to a LEFT JOIN.

·                SELECT    department.department, department.location,
·                          employee.name
·                FROM      employee RIGHT JOIN department
·                ON        employee.department = department.department
·                ORDER BY  department.location, employee.name;
·                 
·                 
·                Results:
·                DEPARTMENT         LOCATION           NAME
·                -------------      ----------------   ----------------
·                Accounting         CA                 Fred
·                MIS                CA                 Jack
·                MIS                CA                 Jill
·                Finance            NJ                 Alice 
·                Finance            NJ                 Joe
·                Marketing          NY                 NULL 
·                SELECT MAX(employee.salary) 
·                FROM   employee, department
·                WHERE  employee.department = department.department
·                AND    department.location = 'CA';
·                 
·                Results:
·                    MAX(SALARY) 
·                    ------------
·                    48000
·                SELECT *
·                FROM    employee, department;
·                 
·                 
·                Results:
·                Name       employee.Departmen Salary  Department.Dep Location 
·                 Joe       Finance            50000   Finance        NJ       
·                 Joe       Finance            50000   MIS            CA       
·                 Joe       Finance            50000   Accounting     CA       
·                 Joe       Finance            50000   Marketing      NY       
·                 Alice     Finance            52000   Finance        NJ       
·                 Alice     Finance            52000   MIS            CA       
·                 Alice     Finance            52000   Accounting     CA       
·                 Alice     Finance            52000   Marketing      NY       
·                 Jill      MIS                48000   Finance        NJ       
·                 Jill      MIS                48000   MIS            CA       
·                 Jill      MIS                48000   Accounting     CA       
·                 Jill      MIS                48000   Marketing      NY       
·                 Jack      MIS                32000   Finance        NJ       
·                 Jack      MIS                32000   MIS            CA       
·                 Jack      MIS                32000   Accounting     CA       
·                 Jack      MIS                32000   Marketing      NY       
·                 Fred      Accounting         33000   Finance        NJ       
·                 Fred      Accounting         33000   MIS            CA       
·                 Fred      Accounting         33000   Accounting     CA       
·                 Fred      Accounting         33000   Marketing      NY       
·                SELECT    DISTINCT location
·                FROM      department;
·                SELECT   customers.LastName, Sum(Balance) 
·                FROM     customers, accounts
·                WHERE    customers.CustomerID = accounts.customerid
·                GROUP BY customers.LastName
·                 
·                Results:
·                 
·                LASTNAME    SUM(BALANCE)
·                ---------   ------------
·                Axe         $15,000.00 
·                Builder     $1,300.00 
·                Jones       $1,000.00 
·                Smith       $6,000.00 
·                SELECT   customers.LastName, Sum(Balance) AS TotalBalance
·                FROM     customers, accounts
·                WHERE    customers.CustomerID = accounts.customerid
·                GROUP BY customers.LastName
·                 
·                Results:
·                 
·                LASTNAME    TotalBalance
·                ---------   ------------
·                Axe         $15,000.00 
·                Builder     $1,300.00 
·                Jones       $1,000.00 
·                Smith       $6,000.00 
·                SELECT name, department,
·                       salary  AS CurrentSalary,
·                       (salary * 1.03)  AS ProposedRaise
·                FROM   employee;
·                 
·                Results:
·                 
·                name      department    CurrentSalary  ProposedRaise
·                --------  ------------  -------------  -------------
·                Alice     Finance       52000          53560 
·                Fred      Accounting    33000          33990 
·                Jack      MIS           32000          32960 
·                Jill      MIS           48000          49440 
·                Joe       Finance       50000          51500 
·                 
·                 

Recursive Queries and Aliases

StudentID

Name

Student_TutorID

S101

Bill

NULL

S102

Alex

S101

S103

Mary

S101

S104

Liz

S103

S105

Ed

S103

S106

Sue

S101

S107

Petra

S106

·                SELECT   s1.name AS Student,  tutors.name AS Tutor
·                FROM     students s1,  students tutors
·                WHERE    s1.student_tutorid = tutors.studentid;
·                 
·                 
·                Results:
·                 
·                Student       Tutor 
·                ----------    ----------
·                Alex          Bill 
·                Mary          Bill 
·                Sue           Bill 
·                Liz           Mary 
·                Ed            Mary 
·                Petra         Sue 
·                SELECT   s1.name AS Student,  tutors.name AS Tutor
·                FROM     students s1   LEFT JOIN   students tutors
·                ON       s1.student_tutorid = tutors.studentid;
·                 
·                Results:
·                 
·                Student       Tutor 
·                ----------    ----------
·                Bill 
·                Alex          Bill 
·                Mary          Bill 
·                Sue           Bill 
·                Liz           Mary 
·                Ed            Mary 
·                Petra         Sue 
·                SELECT   s1.name AS TutorName,
·                         COUNT(tutors.student_tutorid) AS NumberTutored
·                FROM     students s1, students tutors
·                WHERE    s1.studentid = tutors.student_tutorid
·                GROUP BY s1.name;
·                 
·                Results:
·                 
·                TutorName   NumberTutored
·                ----------  -------------
·                Bill Smith              3
·                Mary Green              2
·                Sue Carr                1

WHERE Clause Expressions

·                   <    >    =   !=    <=    >=

Also consider BETWEEN

SELECT name, grade, "You Got a B"
FROM   students
WHERE  grade between 81 and 90
 
·                SELECT name, grade 
·                FROM   students
·                WHERE  grade = 
·                  (  SELECT MAX(grade) FROM students
·                  );

This assumes the subquery returns only one tuple as a result.
Typically used for aggregate functions.

·                SELECT    name
·                FROM      employee 
·                WHERE     department IN ('Finance', 'MIS');
·                 
·                 
·                SELECT    name
·                FROM      employee 
·                WHERE     department IN 
·                          (SELECT department
·                           FROM departments
·                           WHERE location = 'CA');

In the above case, the subquery returns a set of tuples. The IN clause returns true when a tuple matches a member of the set.

·                SELECT   name, salary
·                FROM     employee
·                WHERE    EXISTS
·                         (SELECT  name 
·                          FROM    EMPLOYEE e2
·                          WHERE   e2.salary > employee.salary)
·                     AND EXISTS
·                         (SELECT  name 
·                          FROM    EMPLOYEE e3
·                          WHERE   e3.salary < employee.salary)
·                 
·                Results:
·                name          salary
·                -----------   ---------- 
·                Joe           50000 
·                Jill          48000 
·                Fred          33000 
·                 

The above query shows all employees names and salaries where there is at least one person who makes more money (the first exists) and at least one person who makes less money (second exists).

·                SELECT   name, salary
·                FROM     employee
·                WHERE    NOT EXISTS
·                         (SELECT  name 
·                          FROM    EMPLOYEE e2
·                          WHERE   e2.salary > employee.salary)
·                 
·                Results:
·                name        salary       
·                ---------   ----------
·                Alice       52000 
·                 
·                 

The above query shows all employees for whom there does not exist an employee who is paid less.

Show all employees whose name starts with 'S'

SELECT   name, salary 
FROM     employee
WHERE    name LIKE  'S%';

Show all employees whose name contains the letters 'en'

SELECT   name, salary 
FROM     employee
WHERE    name LIKE  '%en%';

Note that chatacters within quotes are case sensitive.

Show all employees whose name contains the letter 'e' and the letter 'n' in that order:

SELECT   name, salary 
FROM     employee
WHERE    name LIKE  '%e%n%';

Show all employees whose name contains the letter 'e' and the letter 'n' in any order:

SELECT   name, salary 
FROM     employee
WHERE    name LIKE  '%e%n%' OR
         name LIKE  '%n%e%';

Deleting Tuples with DELETE

·                  DELETE employee;
  
·                  DELETE employee
·                  WHERE  salary  > 50000;
  
·                  DELETE employee
·                  WHERE  department IN
·                    (SELECT department
·                     FROM   department
·                     WHERE  location = 'CA');
  

Change Values using UPDATE

·                UPDATE employee
·                SET    last_name = 'Smith'
·                WHERE  employee_id = 'E1001';
·                UPDATE employee
·                SET    salary = salary * 1.05
·                WHERE  employee_id = 'E1001';

Defining Views

·                CREATE VIEW emp_address AS
·                       SELECT first_name, last_name, street, 
·                              city, state, zip
·                       FROM   employee;
·                 
·                 
·                CREATE VIEW emp_salary AS
·                       SELECT first_name, last_name, salary
·                       FROM employee;
·                 
·                 
·                CREATE VIEW avg_sal_dept AS
·                       SELECT    department, AVG(salary)
·                       FROM      employee
·                       GROUP BY  department;
·                SELECT   * 
·                FROM     emp_address
·                ORDER BY last_name;
·                 
·                SELECT  *
·                FROM    avg_sal_dept
·                WHERE   department = 'Finance';
·                 

 

How is Oracle implemented on Windows NT and 2000?

Oracle on Windows NT and 2000 is running as a service that is implemented as a single multi-threaded process:

Services: Oracle on Windows NT and 2000 doesn't run as typical Windows processes, but as a Windows service. A service is basically a background process that is independent of who is using the console or system at any particular time. Services can be started at system boot time and can be compared to Unix daemon processes. To check that the required Oracle services are up and running, go to CONTROL PANEL/ SERVICES (or type "net start | more" from a DOS console window).

Multi Threaded: Unlike on Unix, the Oracle instance on NT and 2000 is implemented as a single operating system process. This process include threads that implement each of the tasks required for the instance to function. Therefore, there is a thread for each of the background (lgwr, dbwr, arch, etc.) and server tasks, plus a two-thread overhead. Because each thread shares the same memory space, there is no need to implement the SGA in shared memory. All memory it is available to all threads within the process.

·  Back to top of file


Should one use NT Workstation, NT Server or Windows 2000 to run Oracle?

Windows NT comes in two flavours: Workstation and Server. These terms are highly misleading, suggesting that a machine with server functions should run NT Server. That is not the case at all. The distinction between Workstation and Server is only important to NT itself. The Server product includes the NT domain administration tools and services. If you have more than one NT machine in a network you will probably want one of them to be an NT Server machine to act as the domain controller, but you probably DON'T want to run the Oracle database server on that machine.

The Oracle database server and tools will run equally well on an NT "Workstation" machine as on an NT "Server" machine, unless the Server machine is the Domain Controller for a busy domain, in which case it would be a poor choice to host a busy database server as well.

The same applies to the different Windows 2000 releases.

·  Back to top of file


How does one use the Oracle supplied command line utilities?

Most oracle command line utilities are stored in the %ORACLE_HOME%\bin subdirectory. Some of the supplied command line utilities are: sqlplus, svrmgrl, imp, exp, sqlldr, etc.

For Oracle releases below 8i, these command will have a XX suffix (eg svrmgr30), where XX is the utility's version number.

Before using any of these utilities, set the required environment variables. Look at this example:

         DOS> set oracle_sid=oracle

         DOS> svrmgrl

·  Back to top of file


How does one create a new database on NT/ 2000?

One can create a "starter" database as part of the installation process. If you need to create any additional databases, one can use the Oracle Database Configuration Assistant (DBAssist) GUI utility.

One can also create a new database from the Console Window. Start by generating some sample scripts using the Database Configuration Assistant. Modify them according to your standards, and run them to create your database.

·  Back to top of file


What Oracle services must be running on a NT/2000 box?

For Oracle 8i and above, one can start the database by starting the OracleServiceSID service. For Oracle versions below 8i one should see at least two services - OracleStartSID and OracleServiceSID.

Some of the other optional services are:

·  Back to top of file


How can I automatically start Oracle on NT/2000?

To start a database automatically when your server boots up, ensure the following registry setting is enabled: ORA_sid_AUTOSTART.

One can also specify autostart when creating new database services. Verify if this was done by opening Control Panel -> Services (Control Panel -> Administrative Tools -> Services on Windows 2000) and check if it is set to AUTOMATIC.

You may need to recreate the services mentioned above using the "oradim" (Instance Manager) utility. Start by opening a DOS command console window. Look at this example (assume a SID of TEST):

         rem Delete the old service

         ORADIM -DELETE -SID test -SRVC servicename

 

         rem Create a new services with the STARTMODE AUTO property

         oradim -new -sid TEST -intpwd ORACLE -startmode AUTO -pfile C:\orant\admin\TEST\pfile\initTEST.ora

·  Back to top of file


Can one start and stop services from a batch job?

Issue commands similar to these from a batch file:

        net start "OracleAgent"

        net start "OracleServiceSID" /y

        net start "OracleTNSListener"

        net start "OracleWWWListener9999"

To stop the services, use net stop instead of net start.

These commands are handy if you need to shut down the database for a cold (offline) backup. Do not put this batch file in your Windows startup group as the database will then only start when someone logs onto the server. The database will not start if the server is re-booted and waits on the log-on screen.

The following registry entries are also handy to prevent a SHUTDOWN ABORT when the OracleServiceSID service is stopped:

        [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE]

        "ORA_SID_SHUTDOWN"="TRUE"

        "ORA_SID_SHUTDOWN_TIMEOUT"="60"

·  Back to top of file


How does one kill Oracle processes on NT/2000?

One normally kills Oracle processes using the "alter system kill session" command. One can also use the orakill.exe command that comes with Oracle for NT/2000 to kill a thread. You need to specify the thread ID in Hex. Try orakill /? or orakill /h for more details. Example:

         SQL> select spid as thread, osuser, s.program

         SQL> from   sys.v_$process p, sys.v_$session s

         SQL> where  p.addr = s.paddr;

 

         DOS> orakill.exe sid thread

·  Back to top of file


How does one take a hot database backup on NT/2000?

You need to use the Oracle OCOPY.EXE utility on Windows NT/2000 to backup open database files (e.g. do a hotbackup).

The NTBACKUP command will not backup open files. Also, OCOPYxx.exe (e.g. OCOPY80.EXE distributed with Oracle8.0) will not backup files to tape, only to another disk location. Once the hotbackup to disk is complete, you can use the NTBACKUP utility to backup the files to tape.

Note 1: If you perform a hot backup your databases must run in archivelog mode, otherwise shutdown and do a cold backup. Read the Oracle Backup and Recovery FAQ for more details.

·  Back to top of file


Can I schedule backups and maintenance jobs on NT/2000?

Yes, make sure the SCHEDULE service is running (control panel/ services/ schedule). You can now schedule jobs by issuing the AT command. Eg:

        C:>at 12:00pm "my_backup"

        Added a new job with job ID = 0

To get a list of scheduled jobs, execute the AT command without any parameters: Eg:

        C:>at

        Status ID   Day                     Time          Command Line

        ----------------------------------------------------------------

                0   Tomorrow                12:00 PM      my_backup

For more info, type AT /?

Also note that several alternatives exist to the AT command. For example, there is a GUI utility in the NT Resource Kit CD-ROM for scheduling jobs. This utility will (supposedly) become part of the OS with version 5.0. It's a lot more convenient to use than its command-line counterpart AT.

·  Back to top of file


How can I fool Oracle to think a remote database is local?

Some products, like Oracle WebDB, require a local Oracle database. You can direct all connect requests to a TNSNAMES.ORA connect descriptor by setting the LOCAL string in your Windows registry. Whenever you now connect to a database without a connect string, the remote database will be used.

PS: In a BAT or CMD file, you can just do a "set LOCAL=alias_name".

·  Back to top of file


Any performance tuning tips for Oracle on NT/2000?

·  Back to top of file


What NT/2000 commands can be used when administrating my database?

You may find the following commands useful:

at

Schedule jobs to run

hostname

Your machine name. Listed in LISTENER.ORA.

ipconfig

Your machine's IP address. Listed in LISTENER.ORA.

netstat

Monitor network connections.

·  Back to top of file


Is there a decent scripting environment for Windows NT/2000?

Third-party scripting languages like Perl and Python can be downloaded and installed on Windows NT and 2000 systems. Perl (my favorite) can be downloaded from www.activeperl.com. Python can be downloaded from www.python.org.

Microsoft's commercial solution to the lack of a proper scripting language is called Microsoft SFS (Services for UNIX). SFS ships with a Unix borne shell, ActiveState Perl and other common Unix utilities like ls, crontab, grep, vi, top, ps, kill, etc. It also includes a Telnet Server to provide terminal access to your NT/2000 machines. This is extremely handy if you need to work from home.

More information about Windows Services for UNIX can be obtained from www.microsoft.com/windows/sfu.

·  Back to top of file


What is the difference between FailSafe and Oracle Parallel Server?

Both Oracle FailFave and Parallel Server runs on Clustered Hardware.

Oracle FailSafe provides a high-availability database solution for Windows NT/2000 clusters. In the event of system failure, FailSafe will recover and restart the database on an alternative node within the cluster.

Oracle Parallel Server clusters databases for providing high availability and scalability through the use of shared storage systems. It allows users on multiple nodes to access a common Oracle database simultaneously. It enables multiple Oracle Server instances to run on different nodes of a cluster while providing concurrent access to common data.

·  Back to top of file


Does Parallel Server use MS Clustering Services (MSCS)?

No. Oracle Parallel Server (OPS) and Real Application Clusters (RAC) contains its own clustering services for all Intel (Windows/ Linux) platforms. This means that an OPS/RAC cluster only provides high availability for the database environment.

·  Back to top of file


What are the Oracle Services for MTS?

The Oracle Services for MTS allow an Oracle database to act as a resource manager in a MTS (Microsoft Transaction Server)/DTC transaction environment. This is possible because the Oracle Database supports the XA standard.

Some of the benefits that MTS provides are:

·  Back to top of file


Where can one get more info about Windows NT/2000?

 


1. Different Oracle versions must be installed into different Oracle Homes.
2. Sql*Net settings should be set for each home sparately. You may share that settings among several homes by seting TNS_ADMIN environment variable.

I have 3 different clients on my W2K PC: 8.0.6, 8.1.7 and 9.0.2 and each of them successfully works with the same set of databases from 8.0.5 to 9.2.0 installed on W2K, HP-UX, Solaris and Linux.

We have an issue where different applications require different versions of the oracle client to run properly(i.e. 8.05 & 8.16). Can you install both versions of the oracle client on a NT workstation (say in c:\ora805 and c:\ora816) and use the oracle home selector to toggle between the two? Has anyone tried this and if so, where there any issues?

With Oracle flexible architecture (OFA), you can install and maintain multiple Oracle homes (i.e., multiple versions) for both server and clients. By default with OFA, version 8.0.5 is installed in drv:\oracle\ora80 while version 8.1.6 is installed in drv:\oracle\ora81.