13
A database in MySQL is a schema in Oracle MySQL has a single daemon that runs the database server. Within the server you can create any number of databases - these databases have no direct mapping to users. Oracle has a single database. When you create a user in an Oracle database, it also creates a Schema with the same name as the user that created it. This is equivalent to a database in MySQL . Y ou really need to forget about mysql while you learn Oracle. DDL and RDBMS concepts are completely different. Start with the Oracle Server Concepts guide ( link ). The Oracle documentation home is here: http://www.oracle.com/pls/db112/homepage In Oracle, schema contains all the tables, constraints, etc. When in mysql you create create database , in Oracle you create schema. In Oracle You don't use db1 , but alter session set CURRENT_SCHEMA = db1 . Each user has it's own schema, so you get list of schemas by select USERNAME from SYS.ALL_USERS The Oracle definition of a database is the files on disk. These can be shared between instances (Real Application Clusters) or only used by a single instance Background: The concept of "database" is different between database vendors. As an Oracle DBA I'm careful when talking to someone who is from an MySQL, DB2, SQL Server background, what they call a "database" in Oracle is a user/schema (difference between user and schema being a schema contains tables and a user is only a login). Whenever someone, developer especially, uses the word "database" question in what context.

Mysql-Oracle - Schema, Instance, Etc

  • Upload
    fraspi

  • View
    7

  • Download
    3

Embed Size (px)

DESCRIPTION

Mysql-Oracle - Schema, Instance, Etc

Citation preview

A database in MySQL is a schema in OracleMySQL has a single daemon that runs the database server. Within the server you can create any number of databases - these databases have no direct mapping to users.Oracle has a single database. When you create a user in an Oracle database, it also creates a Schema with the same name as the user that created it. This is equivalent to a database in MySQL.

You really need to forget about mysql while you learn Oracle. DDL and RDBMS concepts are completely different.Start with the Oracle Server Concepts guide (link). The Oracle documentation home is here: http://www.oracle.com/pls/db112/homepage

In Oracle, schema contains all the tables, constraints, etc. When in mysql you create create database , in Oracle you create schema. In Oracle You don'tuse db1, butalter session set CURRENT_SCHEMA = db1.Each user has it's own schema, so you get list of schemas byselect USERNAME from SYS.ALL_USERS

The Oracle definition of a database is the files on disk. These can be shared between instances (Real Application Clusters) or only used by a single instance

Background: The concept of "database" is different between database vendors. As an Oracle DBA I'm careful when talking to someone who is from an MySQL, DB2, SQL Server background, what they call a "database" in Oracle is a user/schema (difference between user and schema being a schema contains tables and a user is only a login). Whenever someone, developer especially, uses the word "database" question in what context.

Difference between Oracle Instance, database, schema and user account

A database is the set of files where data is stored

An instance is the set of processes that manipulate the database. For most folks, there is one instance per database. You can get multiple instances per database when you're using RAC though.

A user account is just a login to the database

A schema is the set of objects owned by a particular user account. Most user accounts should not own any objects, so they are often not associated with a schema.-- --

An Oracle instance is in essense a set of Oracle server processes and a shared memory segment called the SGA. Think of it as the Database Server Engine.

The Oracle database is a physical database - and is not the same as a SQL-Server or mySQL database. A single physical Oracle database is capable of containing 1000's of logical databases.

An Oracle schema is in fact a logical database. This equates to the databases you get in SQL-Server and mySQL.

The norm in Oracle is to have a single Oracle Instance and a single Oracle Physical Database per platform. This scales a lot better than having multiple Instances and Physical Databases in order to emulate how SQL-Server for example looks like.

A single Oracle Instance is capable of servicing 10's of 1000's of users. And as I mentioned, a single Physical Database can have 1000's of logical databases in it. Oracle even extends the logical database, allowing you to create Virtual Private Databases. This allows you to use a single logical database (same tables and same code) for multiple customers/users, without any one customer/user being able to see the data of another.

As for scalability - that is RAC (Real Application Clusters) that Justin mentioned.

A RAC is a single Physical Database. Usually residing on a shared storage medium like a SAN. It has Multiple Oracle Instances - one per platform.

So you wind up with a number of database engines, one per platform, for the same physical database. This address issues such as high availability (one platform fails and there are still other db engines for the database running). And scalability - more users can be supported and one Database Instance can enlist the assistance of other Instances to run complex queries using massive parallel processing.

-- --

A database is a collection of physical operating system files (parameter files, data files, redo log files, control files, temp files, password files). A database is identified by its SID (system identifier - a name chosen on creation - usually describing its purpose e.g. 'LIVE', 'QA', 'DEVEL').

An instance is a set of Oracle processes (on unix / linux this will be pmon, smon, lgwr, dbwr etc - on windows these will be threads in oracle.exe) and an SGA (a shared memory structure containing the Fixed SGA, the shared pool, redo buffer, block buffers etc).

More than one instance can mount and open the same database at the same time (Oracle RAC for example, or old style Oracle Parallel Server). An instance can only mount and open one database at a time.

Most oracle users tend to think of a Database and an Instance as interchangeable terms - fair enough for normal conversation as long as you remember the real definitions - especially if working in a clustered environment or talking to a DBA.

A Schema is all the database objects created by a database user (e.g. tables, indexes, database packages). A database can contain many schemas.

--- ---

Instance, Database and Schema: The distinction between these three is probably one of the most confusing concepts across different RDBMS since different RDBMS have different architectures and different terminologies. To put it simply in Oracle lingo, a database is a set of files (data files, redo log files, control files and so on). An instance is a set of processes (SMON, PMON, MMON, DBWR, etc) and a shared memory segment (SGA). A database may be mounted and opened by many instances (RAC installation) concurrently (this is to do with the shared everything architecture of Oracle RAC). An instance may mount and open any database however it may only open a single database at any time. So, in ERD terms: Database:Instance :: 1:N (a one to many relationship) in Oracle. A schema is the container of the schema objects so all the tables, views, procedures, packages, views etc. reside in the schema. There can be multiple schemas per database.In the case of DB2 and SQL Server, an instance can have many databases which internally can have many schemas. In the case of Informix, an instance can have many databases and there is no concept of schemas. For the sake of simplicity, we refer a database as the container for the different schemas and a schema to be the one that contains all the schema objects (tables, views, procedures, packages, sequences etc.).

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

SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to the be files.Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to SALES.acme.com", the DBA can on the fly change the number of instances which are available to SALES.acme.com requests, or even move SALES.acme.com to a completely different database without the client needing to change any settings--- ---Oracle SID is the unique name that uniquely identifies your instance/database where as Service name is the TNS alias that you give when you remotely connect to your database and this Service name is recorded in Tnsnames.ora file on your clients and it can be the same as SID and you can also give it any other name you want.SERVICE_NAME is the new feature from oracle 8i onwards in which database can register itself with listener. If database is registered with listener in this way then you can use SERVICE_NAME parameter in tnsnames.ora otherwise - use SID in tnsnames.ora.Also if you have OPS (RAC) you will have different SERVICE_NAME for each instance.SERVICE_NAMES specifies one or more names for the database service to which this instance connects. You can specify multiple services names in order to distinguish among different uses of the same database. For example:SERVICE_NAMES = sales.acme.com, widgetsales.acme.comYou can also use service names to identify a single service that is available from two different databases through the use of replication.

--- ---

SID menas System Identification Number so for each instance there is a unique SID in the server. Service_Name is nothing but a name alias for the the database name in a non RAC system. But in a RAC system it has some other additional functionalities.

Yes you can create a single listener for a 9i,10g and 11g database but make sure when you are starting the listener you should start it from Higher version , here in your case you should start the listener from 11g binaries.

--- ---

The sid identifies the instance, the service_name the database..

ORACLE INSTANCEA databaseinstanceis a set of memory structures that manage database files. Adatabaseis a set of physical files on disk created by theCREATE DATABASEstatement. The instance manages its associated data and serves the users of the database.Every running Oracle database is associated with at least one Oracle database instance. Because an instance exists in memory and a database exists on disk, an instance can exist without a database and a database can exist without an instance.

http://docs.oracle.com/cd/E11882_01/server.112/e25789/toc.htmhttp://docs.oracle.com/cd/E11882_01/index.htm

Database and InstanceAn Oracle database server consists of adatabaseand at least one databaseinstance(commonly referred to as simply aninstance). Because an instance and a database are so closely connected, the termOracle databaseis sometimes used to refer to both instance and database. In the strictest sense the terms have the following meanings: DatabaseA database is a set of files, located on disk, that store data. These files can exist independently of a database instance. Database instanceAn instance is a set of memory structures that manage database files. The instance consists of a shared memory area, called thesystem global area (SGA), and a set ofbackground processes. An instance can exist independently of database files.Figure 1-1shows a database and its instance. For each user connection to the instance, the application is run by aclient process. Each client process is associated with its own server process. The server process has its own private session memory, known as theprogram global area (PGA).Figure 1-1 Oracle Instance and Database

Description of "Figure 1-1 Oracle Instance and Database"A database can be considered from both a physical and logical perspective. Physical data is data viewable at the operating system level. For example, operating system utilities such as the Linuxlsandpscan list database files and processes. Logical data such as a table is meaningful only for the database. A SQL statement can list the tables in an Oracle database, but an operating system utility cannot.The database hasphysical structuresandlogical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting access to logical storage structures. For example, renaming a physical database file does not rename the tables whose data is stored in this file.See Also:Chapter 13, "Oracle Database Instance"Database Storage StructuresAn essential task of a relational database is data storage. This section briefly describes the physical and logical storage structures used by Oracle Database.Physical Storage StructuresThe physical database structures are the files that store the data. When you execute the SQL commandCREATE DATABASE, the following files are created: Data filesEvery Oracle database has one or more physicaldata files, which contain all the database data. The data of logical database structures, such as tables and indexes, is physically stored in the data files. Control filesEvery Oracle database has acontrol file. A control file contains metadata specifying the physical structure of the database, including the database name and the names and locations of the database files. Online redo log filesEvery Oracle Database has anonline redo log, which is a set of two or moreonlineredo log files. An onlineredo logis made up of redo entries (also calledredo records), which record all changes made to data.Many other files are important for the functioning of an Oracle database server. These files include parameter files and diagnostic files. Backup files andarchived redo log filesare offline files important for backup and recovery.See Also:Chapter 11, "Physical Storage Structures"Logical Storage StructuresThis section discusses logical storage structures. The following logical storage structures enable Oracle Database to have fine-grained control of disk space use: Data blocksAt the finest level of granularity, Oracle Database data is stored in data blocks. Onedata blockcorresponds to a specific number of bytes on disk. ExtentsAnextentis a specific number of logically contiguous data blocks, obtained in a single allocation, used to store a specific type of information. SegmentsAsegmentis a set of extents allocated for a user object (for example, a table or index),undo data, or temporary data. TablespacesA database is divided into logical storage units calledtablespaces. A tablespace is the logical container for a segment. Each tablespace contains at least one data file.See Also:Chapter 12, "Logical Storage Structures"Database Instance StructuresAn Oracle database uses memory structures and processes to manage and access the database. All memory structures exist in the main memory of the computers that constitute the RDBMS.When applications connect to an Oracle database, they are connected to a database instance. The instance services applications by allocating other memory areas in addition to the SGA, and starting other processes in addition to background processes.Oracle Database ProcessesAprocessis a mechanism in an operating system that can run a series of steps. Some operating systems use the termsjob,task, orthread. For the purpose of this discussion, a thread is equivalent to a process. An Oracle database instance has the following types of processes: Client processesThese processes are created and maintained to run the software code of an application program or an Oracle tool. Most environments have separate computers for client processes. Background processesThese processes consolidate functions that would otherwise be handled by multiple Oracle Database programs running for each client process. Background processes asynchronously perform I/O and monitor other Oracle Database processes to provide increased parallelism for better performance and reliability. Server processesThese processes communicate with client processes and interact with Oracle Database to fulfill requests.Oracle processesinclude server processes and background processes. In most environments, Oracle processes and client processes run on separate computers.See Also:Chapter 15, "Process Architecture"Instance Memory StructuresOracle Database creates and uses memory structures for purposes such as memory for program code, data shared among users, and private data areas for each connected user. The following memory structures are associated with an instance: System Global Area (SGA)The SGA is a group of shared memory structures that contain data and control information for one database instance. Examples of SGA components include cached data blocks and shared SQL areas. Program Global Areas (PGA)A PGA is a memory region that contain data and control information for a server or background process. Access to the PGA is exclusive to the process. Each server process and background process has its own PGA.See Also:Chapter 14, "Memory Architecture"