Tuesday, March 3, 2009

SHAKTI TRADERS


This is my honor to introduce myself as one of the most successful provider of Bamboos and its products in Maharashtra. From last 40 years, it’s been a really a pleasure to service our customers with world class quality of bamboos and theirs products. And achieving their believes as one of the most trusted business house in bamboo. Business is really a reward of our 40 years of continuous efforts. Our vision is to satisfy our customers with best service and products and at reasonable price.

Contact:

SHAKTI TRADERS

13A, Adarsha Nagar, Kharbi Square, Ring Road, Nagpur. Maharshtra 440009, India.
+0091-9970463226

29 comments:

  1. 13A, Adarsha Nagar, Kharbi Square, Ring Road, Nagpur. Maharshtra 440009

    9970463226

    ReplyDelete
  2. MYSQL COMMANDS
    To login (from unix shell) use -h only if needed.

    # [mysql dir]/bin/mysql -h hostname -u root -p
    Create a database on the sql server.

    mysql> create database [databasename];
    List all databases on the sql server.

    mysql> show databases;
    Switch to a database.

    mysql> use [db name];
    To see all the tables in the db.

    mysql> show tables;
    To see database's field formats.

    mysql> describe [table name];
    To delete a db.

    mysql> drop database [database name];
    To delete a table.

    mysql> drop table [table name];
    Show all data in a table.

    mysql> SELECT * FROM [table name];
    Returns the columns and column information pertaining to the designated table.

    mysql> show columns from [table name];
    Show certain selected rows with the value "whatever".

    mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";
    Show all records containing the name "Bob" AND the phone number '3444444'.

    mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';
    Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.

    mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;
    Show all records starting with the letters 'bob' AND the phone number '3444444'.

    mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';
    Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.

    mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;
    Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

    mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";
    Show unique records.

    mysql> SELECT DISTINCT [column name] FROM [table name];
    Show selected records sorted in an ascending (asc) or descending (desc).

    mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
    Return number of rows.

    mysql> SELECT COUNT(*) FROM [table name];
    Sum column.

    mysql> SELECT SUM(*) FROM [table name];
    Join tables on common columns.

    mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
    Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

    # mysql -u root -p
    mysql> use mysql;
    mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
    mysql> flush privileges;
    Change a users password from unix shell.

    # [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'
    Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

    # mysql -u root -p
    mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
    mysql> flush privileges;
    Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

    # /etc/init.d/mysql stop
    # mysqld_safe --skip-grant-tables &
    # mysql -u root
    mysql> use mysql;
    mysql> update user set password=PASSWORD("newrootpassword") where User='root';
    mysql> flush privileges;
    mysql> quit
    # /etc/init.d/mysql stop
    # /etc/init.d/mysql start
    Set a root password if there is on root password.

    # mysqladmin -u root password newpassword
    Update a root password.

    ReplyDelete
  3. MYSQL COMMANDS:-
    # mysqladmin -u root -p oldpassword newpassword
    Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

    # mysql -u root -p
    mysql> use mysql;
    mysql> grant usage on *.* to bob@localhost identified by 'passwd';
    mysql> flush privileges;
    Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

    # mysql -u root -p
    mysql> use mysql;
    mysql> INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
    mysql> flush privileges;

    or

    mysql> grant all privileges on databasename.* to username@localhost;
    mysql> flush privileges;
    To update info already in a table.

    mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
    Delete a row(s) from a table.

    mysql> DELETE from [table name] where [field name] = 'whatever';
    Update database permissions/privilages.

    mysql> flush privileges;
    Delete a column.

    mysql> alter table [table name] drop column [column name];
    Add a new column to db.

    mysql> alter table [table name] add column [new column name] varchar (20);
    Change column name.

    mysql> alter table [table name] change [old column name] [new column name] varchar (50);
    Make a unique column so you get no dupes.

    mysql> alter table [table name] add unique ([column name]);
    Make a column bigger.

    mysql> alter table [table name] modify [column name] VARCHAR(3);
    Delete unique from table.

    mysql> alter table [table name] drop index [colmn name];
    Load a CSV file into a table.

    mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
    Dump all databases for backup. Backup file is sql commands to recreate all db's.

    # [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
    Dump one database for backup.

    # [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
    Dump a table from a database.

    # [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
    Restore database (or database table) from backup.

    # [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql
    Create Table Example 1.

    mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));
    Create Table Example 2.

    mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. ORACLE PLUG-IN
    =========================
    Oracle Wallet Functions
    Once the oracle is install then must dounloads the wallet. Without the oracle notable to enter Oracle enterprise manger. If the wallet is not create then create new the wallet 1st from wallet.
    Local copy Path: C:\Documents and Settings\sacgai\ORACLE\WALLETS\
    Used the oracle enterprise assistant and download an oracle wallet from directory serves.
    Security administrators use Oracle Wallet Manager to manage public-key security credentials on both client and server systems. Security credentials, consisting of a public/private key pair, a certificate, and a trusted certificate, are stored in and accessed from a logical container called a wallet. Wallets can be accessed by using both Oracle Wallet Manager and Oracle Enterprise Login Assistant.

    Oracle Wallet Manager is a standalone Java application that wallet owners use to manage and edit the security credentials in their Oracle wallets. These tasks include the following:
    • Generating a public/private key pair and creating a certificate request for submission to a CA.
    • Installing a certificate for the entity.
    • Configuring trusted certificates for the entity.
    • Opening a wallet to enable access to PKI-based services.
    • Creating a wallet that can be accessed by using either Oracle Enterprise Login Assistant or Oracle Wallet Manager.
    • Uploading a wallet to an LDAP directory.
    • Downloading a wallet from an LDAP directory.
    • Importing wallets.
    • Exporting wallets.
    Enterprise Login Assistant Dialog The Enterprise Login Assistant main dialog allows you to log into your wallet or digital cercificate. This dialog consists of the following: Source of Wallet Local Copy: When selected, this option allows you to open an existing wallet on your local system. Location: Location of the Oracle Wallet. By default, the following location is used: /etc/ORACLE/wallets/username. Click Browse to search an alternate wallet location. Password: Wallet password Directory Service: When selected, allows you to download a new wallet from an LDAP directory to your local system. This is required if you are connecting to the enterprise for the very first time. User: Directory username. Password: Directory password. Change Password: Displays the Change Password dialog. Click Change Password to change an enterprise password. Enterprise Login Assistant allows you to change a wallet password, directory password, or a database password.


    Oracle Enterprise Manager
    This chapter describes how Oracle Enterprise Manager can be used to manage Oracle XML DB. Oracle Enterprise Manager can be used to configure, create and manage Repository resources, and database objects such as XML schemas and XMLType tables.
    Oracle Local builder : I helps to define the language format ,date ,

    ReplyDelete
  6. TERMINOLOGY
    #. What are the components of Physical database structure of Oracle Database?
    ORACLE database is comprised of three types of files. One or more Data files, two are more Redo Log files, and one or more Control files.

    #. What are the components of Logical database structure of ORACLE database?
    Tablespaces and the Database's Schema Objects.

    #. What is a Tablespace?
    A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related logical structures together.

    #. What is SYSTEM tablespace and When is it Created?
    Every ORACLE database contains a tablespace named SYSTEM, which is automatically created when the database is

    created. The SYSTEM tablespace always contains the data dictionary tables for the entire database.

    #. Explain the relationship among Database, Tablespace and Data file Each databases logically divided into one or more tablespaces One or more data files are explicitly created for each

    tablespace.

    #. What is schema?
    A schema is collection of database objects of a User.

    #. What are Schema Objects ?
    Schema objects are the logical structures that directly refer to the database's data. Schema objects include tables, views,

    sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and database links.

    #. Can objects of the same Schema reside in different tablespaces.?
    Yes.

    #. Can a Tablespace hold objects from different Schemes ?
    Yes.

    #. what is Table ?
    A table is the basic unit of data storage in an ORACLE database. The tables of a database hold all of the user accessible

    data. Table data is stored in rows and columns.

    # What is a View ?
    A view is a virtual table. Every view has a Query attached to it. (The Query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)

    #. Do View contain Data ?
    Views do not contain or store data.

    #. Can a View based on another View ?
    Yes.
    #. What are the advantages of Views ?
    Provide an additional level of table security, by restricting access to a predetermined set of rows and columns of a table.
    Hide data complexity.
    Simplify commands for the user.
    Present the data in a different perpecetive from that of the base table.
    Store complex queries.

    # What is a Sequence ?
    A sequence generates a serial list of unique numbers for numerical columns of a database's tables.

    # What is a Synonym ?
    A synonym is an alias for a table, view, sequence or program unit.

    #. What are the type of Synonyms?
    There are two types of Synonyms Private and Public.

    #. What is a Private Synonyms ?
    A Private Synonyms can be accessed only by the owner.

    ReplyDelete
  7. #. What is a Public Synonyms ?
    A Public synonyms can be accessed by any user on the database.

    #. What are synonyms used for ?
    Synonyms are used to: Mask the real name and owner of an object.Provide public access to an object Provide location transparency for tables, views or program units of a remote database. Simplify the SQL statements for database users.

    #. What is an Index ?
    An Index is an optional structure associated with a table to have direct access to rows, which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.

    #. How are Indexes Update ?
    Indexes are automatically maintained and used by ORACLE. Changes to table data are automatically incorporated into all relevant indexes.

    #. What are Clusters?
    Clusters are groups of one or more tables physically stores together to share common columns and are often used together.

    #. What is cluster Key?
    The related columns of the tables in a cluster are called the Cluster Key.

    #. What is Index Cluster ?
    A Cluster with an index on the Cluster Key.

    #. What is Hash Cluster ?
    A row is stored in a hash cluster based on the result of applying a hash function to the row's cluster key value. All rows with the same hash key value are stores together on disk.

    #. When can Hash Cluster used ?
    Hash clusters are better choice when a table is often queried with equality queries. For such queries the specified cluster key value is hashed. The resulting hash key value points directly to the area on disk that stores the specified rows.

    #. What is Database Link ?
    A database link is a named object that describes a "path" from one database to another.

    #. What are the types of Database Links ?
    Private Database Link, Public Database Link & Network Database Link.

    #. What is Private Database Link ?
    Private database link is created on behalf of a specific user. A private database link can be used only when the owner of the link specifies a global object name in a SQL statement or in the definition of the owner's views or procedures.

    #. What is Public Database Link ?
    Public database link is created for the special user group PUBLIC. A public database link can be used when any user in the associated database specifies a global object name in a SQL statement or object definition.

    #. What is Network Database link ?
    Network database link is created and managed by a network domain service. A network database link can be used when any user of any database in the network specifies a global object name in a SQL statement or object definition.

    #. What is Data Block ?
    ORACLE database's data is stored in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk.

    #. How to define Data Block size ?
    A data block size is specified for each ORACLE database when the database is created. A database users and allocated

    free database space in ORACLE datablocks. Block size is specified in INIT.ORA file and cann't be changed latter.

    #. What is Row Chaining ?
    In Circumstances, all of the data for a row in a table may not be able to fit in the same data block. When this occurs , the data for the row is stored in a chain of data block (one or more) reserved for that segment.

    #. What is an Extent ?
    An Extent is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information.

    #. What is a Segment ?
    A segment is a set of extents allocated for a certain logical structure.

    #. What are the different type of Segments ?
    Data Segment, Index Segment, Rollback Segment and Temporary Segment.

    #. What is a Data Segment ?
    Each Non-clustered table has a data segment. All of the table's data is stored in the extents of its data segment. Each cluster has a data segment. The data of every table in the cluster is stored in the cluster's data segment.

    ReplyDelete
  8. #. What is a Temporary Segment ?
    Temporary segments are created by ORACLE when a SQL statement needs a temporary work area to complete execution. When the statement finishes execution, the temporary segment extents are released to the system for future use.

    #. What is a Data File ?
    Every ORACLE database has one or more physical data files. A database's data files contain all the database data. The data of logical database structures such as tables and indexes is physically stored in the data files allocated for a database.

    #. What are the Characteristics of Data Files ?
    A data file can be associated with only one database. Once created a data file can't change size.One or more data files form a logical unit of database storage called a table space.

    #. What is a Redo Log?
    The set of Redo Log files for a database is collectively known as the database's redo log.

    #. What is the function of Redo Log ?
    The Primary function of the redo log is to record all changes made to data.

    #. What is the use of Redo Log Information ?
    The Information in a redo log file is used only to recover the database from a system or media failure prevents database data from being written to a database's data files.

    #. What does a Control file Contain ?
    A Control file records the physical structure of the database. It contains the following information.
    Database Name Names and locations of a database's files and redolog files.Time stamp of database creation.

    #. What is the use of Control File ?
    When an instance of an ORACLE database is started, its control file is used to identify the database and redo log files

    that must be opened for database operation to proceed. It is also used in database recovery
    #. What is a Data Dictionary ?
    The data dictionary of an ORACLE database is a set of tables and views that are used as a read-only reference about the database.
    It stores information about both the logical and physical structure of the database, the valid users of an ORACLE

    database, integrity constraints defined for tables in the database and space allocated for a schema object and how much of it is being used.

    #. What is an Integrity Constrains ?
    An integrity constraint is a declarative way to define a business rule for a column of a table.

    ReplyDelete
  9. # Can an Integrity Constraint be enforced on a table if some existing table data does not satisfy the constraint ?
    No.

    #. Describe the different type of Integrity Constraints supported by ORACLE ?
    NOT NULL Constraint - Disallows NULLs in a table's column.
    UNIQUE Constraint - Disallows duplicate values in a column or set of columns.
    PRIMARY KEY Constraint - Disallows duplicate values and NULLs in a column or set of columns.
    FOREIGN KEY Constrain - Require each value in a column or set of columns match a value in a related table's

    UNIQUE or PRIMARY KEY.
    CHECK Constraint - Disallows values that do not satisfy the logical expression of the constraint.

    #. What is difference between UNIQUE constraint and PRIMARY KEY constraint ?
    A column defined as UNIQUE can contain NULLs while a column defined as PRIMARY KEY can't contain Nulls.

    #. Describe Referential Integrity ?
    A rule defined on a column (or set of columns) in one table that allows the insert or update of a row only if the value for the column or set of columns (the dependent value) matches a value in a column of a related table (the referenced value). It also specifies the type of data manipulation allowed on referenced data and the action to be performed on dependent data as a result of any action on referenced data.

    #. What are the Referential actions supported by FOREIGN KEY integrity constraint ?
    UPDATE and DELETE Restrict - A referential integrity rule that disallows the update or deletion of referenced data.

    DELETE Cascade - When a referenced row is deleted all associated dependent rows are deleted.

    #. What is self-referential integrity constraint ?
    If a foreign key reference a parent key of the same table is called self-referential integrity constraint.

    #. What are the Limitations of a CHECK Constraint ?
    The condition must be a Boolean expression evaluated using the values in the row being inserted or updated and can't contain subqueries, sequence, the SYSDATE,UID,USER or USERENV SQL functions, or the pseudo columns LEVEL or ROWNUM.

    #. What is the maximum number of CHECK constraints that can be defined on a column ?
    No Limit.

    ####SYSTEM ARCHITECTURE :
    #. What constitute an ORACLE Instance ?
    SGA and ORACLE background processes constitute an ORACLE instance. (or) Combination of memory structure and background process.

    #. What is SGA ?
    The System Global Area (SGA) is a shared memory region allocated by ORACLE that contains data and control information for one ORACLE instance.

    #. What are the components of SGA ?
    Database buffers, Redo Log Buffer the Shared Pool and Cursors

    ReplyDelete
  10. #. What do Database Buffers contain ?
    Database buffers store the most recently used blocks of database data. It can also contain modified data that has not yet been permanently written to disk.

    #. What do Redo Log Buffers contain ?
    Redo Log Buffer stores redo entries a log of changes made to the database.

    #. What is Shared Pool ?
    Shared Pool is a portion of the SGA that contains shared memory constructs such as shared SQL areas.

    #. What is Shared SQL Area ?
    A Shared SQL area is required to process every unique SQL statement submitted to a database and contains information such as the parse tree and execution plan for the corresponding statement.

    #. What is Cursor ?
    A Cursor is a handle ( a name or pointer) for the memory associated with a specific statement.

    #. What is PGA ?
    Program Global Area (PGA) is a memory buffer that contains data and control information for a server process.

    #. What is User Process ?
    A user process is created and maintained to execute the software code of an application program. It is a shadow process created automatically to facilitate communication between the user and the server process.

    #. What is Server Process ?
    Server Process handle requests from connected user process. A server process is in charge of communicating with the user process and interacting with ORACLE carry out requests of the associated user process.

    #. What are the two types of Server Configurations ?
    Dedicated Server Configuration and Multi-threaded Server Configuration.

    #. What is Dedicated Server Configuration ?
    In a Dedicated Server Configuration a Server Process handles requests for a Single User Process.

    #. What is a Multi-threaded Server Configuration ?
    In a Multi-threaded Server Configuration many user processes share a group of server process.

    #. What is a Parallel Server option in ORACLE ?
    A configuration for loosely coupled systems where multiple instance share a single physical database is called Parallel Server.

    #. Name the ORACLE Background Process ?
    DBWR - Database Writer.
    LGWR - Log Writer
    CKPT - Check Point
    SMON - System Monitor
    PMON - Process Monitor
    ARCH - Archiver
    RECO - Recover
    Dnnn - Dispatcher, and
    LCKn - Lock
    Snnn - Server.

    ReplyDelete
  11. #. What Does DBWR do ?
    Database writer writes modified blocks from the database buffer cache to the data files.

    #.When Does DBWR write to the database ?
    DBWR writes when more data needs to be read into the SGA and too few database buffers are free. The least recently used data is written to the data files first. DBWR also writes when CheckPoint occurs.

    #. What does LGWR do ?
    Log Writer (LGWR) writes redo log entries generated in the redo log buffer of the SGA to on-line Redo Log File.

    #. When does LGWR write to the database?
    LGWR writes redo log entries into an on-line redo log file when transactions commit and the log buffer files are full.

    #. What is the function of checkpoint CKPT)?
    The Checkpoint (CKPT) process is responsible for signaling DBWR at checkpoints and updating all the data files and control files of the database.

    #. What are the functions of SMON ?
    System Monitor (SMON) performs instance recovery at instance start-up. In a multiple instance system (one that uses the Parallel Server), SMON of one instance can also perform instance recovery for other instance that have failed SMON also cleans up temporary segments that are no longer in use and recovers dead transactions skipped during crash and instance recovery because of file-read or off-line errors. These transactions are eventually recovered by SMON when the tablespace or file is brought back on-line SMON also coalesces free extents within the database to make free space contiguous and easier to allocate.

    #. What are functions of PMON ?
    Process Monitor (PMON) performs process recovery when a user process fails PMON is responsible for cleaning up the cache and Freeing resources that the process was using PMON also checks on dispatcher and server processes and restarts them if they have failed.

    #. What is the function of ARCH ?
    Archiver (ARCH) copies the on-line redo log files to archival storage when they are full. ARCH is active only when a database's redo log is used in ARCHIVELOG mode.

    #. What is function of RECO ?
    RECOver (RECO) is used to resolve distributed transactions that are pending due to a network or system failure in a distributed database. At timed intervals,the local RECO attempts to connect to remote databases and automatically complete the commit or rollback of the local portion of any pending distributed transactions.

    #. What is the function of Dispatcher (Dnnn) ?
    Dispatcher (Dnnn) process is responsible for routing requests from connected user processes to available shared server processes and returning the responses back to the appropriate user processes.

    #. How many Dispatcher Processes are created ?
    Atleast one Dispatcher process is created for every communication protocol in use.

    #. What is the function of Lock (LCKn) Process ?
    Lock (LCKn) are used for inter-instance locking when the ORACLE Parallel Server option is used.

    #. What is the maximum number of Lock Processes used ?
    Though a single LCK process is sufficient for most Parallel Server systems
    upto Ten Locks (LCK0,....LCK9) are used for inter-instance locking.

    ReplyDelete
  12. DATA ACCESS
    #. Define Transaction ?
    A Transaction is a logical unit of work that comprises one or more SQL statements executed by a single user.

    #. When does a Transaction end ?
    When it is committed or Rollbacked.

    #. What does COMMIT do ?
    COMMIT makes permanent the changes resulting from all SQL statements in the transaction. The changes made by the SQL statements of a transaction become visible to other user sessions transactions that start only after transaction is committed.

    #. What does ROLLBACK do ?
    ROLLBACK retracts any of the changes resulting from the SQL statements in the transaction.

    #. What is SAVE POINT ?
    For long transactions that contain many SQL statements, intermediate markers or savepoints can be declared which can be used to divide a transaction into smaller parts. This allows the option of later rolling back all work performed from the current point in the transaction to a declared savepoint within the transaction.

    #. What is Read-Only Transaction ?
    A Read-Only transaction ensures that the results of each query executed in the transaction are consistant with respect to the same point in time.

    #. What is the function of Optimizer ?
    The goal of the optimizer is to choose the most efficient way to execute a SQL statement.

    #. What is Execution Plan ?
    The combinations of the steps the optimizer chooses to execute a statement is called an execution plan.

    #. What are the different approaches used by Optimizer in choosing an execution plan ?
    Rule-based and Cost-based.

    #. What are the factors that affect OPTIMIZER in choosing an Optimization approach ?
    The OPTIMIZER_MODE initialization parameter Statistics in the Data Dictionary the OPTIMIZER_GOAL parameter of the ALTER SESSION command hints in the statement.

    #. What are the values that can be specified for OPTIMIZER MODE Parameter ?
    COST and RULE.

    PROGRAMMATIC CONSTRUCTS

    #. What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?
    Procedures and Functions,Packages and Database Triggers.

    #. What is a Procedure ?
    A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks.

    #. What is difference between Procedures and Functions ?
    A Function returns a value to the caller where as a Procedure does not.

    #. What is a Package ?
    A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.

    #. What are the advantages of having a Package ?
    Increased functionality (for example,global package variables can be declared and used by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once)

    #. What is Database Trigger ?
    A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in,update to, or delete from a table.

    #. What are the uses of Database Trigger ?
    Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.

    #. What are the differences between Database Trigger and Integrity constraints ?
    A declarative integrity constraint is a statement about the database that is always true. A constraint applies to existing data in the table and any statement that manipulates the table.
    A trigger does not apply to data loaded before the definition of the trigger, therefore, it does not guarantee all data in a table conforms to the rules established by an associated trigger.
    A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used.

    ReplyDelete
  13. DATABASE SECURITY
    #. What are Roles ?
    Roles are named groups of related privileges that are granted to users or other roles.

    #. What are the use of Roles ?
    REDUCED GRANTING OF PRIVILEGES - Rather than explicitly granting the same set of privileges to many users a database administrator can grant the privileges for a group of related users granted to a role and then grant only the role to each member of the group.
    DYNAMIC PRIVILEGE MANAGEMENT - When the privileges of a group must change, only the privileges of the role need to be modified. The security domains of all users granted the group's role automatically reflect the changes made to the role.
    SELECTIVE AVAILABILITY OF PRIVILEGES - The roles granted to a user can be selectively enable (available for use) or disabled (not available for use). This allows specific control of a user's privileges in any given situation.
    APPLICATION AWARENESS - A database application can be designed to automatically enable and disable selective

    roles when a user attempts to use the application.

    #. How to prevent unauthorized use of privileges granted to a Role ?
    By creating a Role with a password.

    #. What is default tablespace ?
    The Tablespace to contain schema objects created without specifying a tablespace name.
    #. What is Tablespace Quota ?
    The collective amount of disk space available to the objects in a schema on a particular tablespace.

    #. What is a profile ?
    Each database user is assigned a Profile that specifies limitations on various system resources available to the user.
    DISTRIBUTED PROCESSING AND DISTRIBUTED DATABASES

    #. What is Distributed database ?
    A distributed database is a network of databases managed by multiple database servers that appears to a user as single logical database. The data of all databases in the distributed database can be simultaneously accessed and modified.

    #. What is Two-Phase Commit ?
    Two-phase commit is mechanism that guarantees a distributed transaction either commits on all involved nodes or rolls back on all involved nodes to maintain data consistency across the global distributed database. It has two phase, a Prepare Phase and a Commit Phase.

    #. Describe two phases of Two-phase commit ?
    Prepare phase - The global coordinator (initiating node) ask a participants to prepare (to promise to commit or rollback the transaction, even if there is a failure)
    Commit - Phase - If all participants respond to the coordinator that they are prepared, the coordinator asks all nodes to commit the transaction, if all participants cannot prepare, the coordinator asks all nodes to roll back the transaction.

    #. What is the mechanism provided by ORACLE for table replication ?
    Snapshots and SNAPSHOT LOGs

    #. What is a SNAPSHOT ?
    Snapshots are read-only copies of a master table located on a remote node which is periodically refreshed to reflect changes made to the master table.

    #. What is a SNAPSHOT LOG ?
    A snapshot log is a table in the master database that is associated with the master table. ORACLE uses a snapshot log to track the rows that have been updated in the master table. Snapshot logs are used in updating the snapshots based on the master table.

    #. What is a SQL * NET?
    SQL *NET is ORACLE's mechanism for interfacing with the communication protocols used by the networks that facilitate distributed processing and distributed databases. It is used in Clint-Server and Server-Server communications.
    DATABASE OPERATION, BACKUP AND RECOVERY

    #. What are the steps involved in Database Startup ?
    Start an instance, Mount the Database and Open the Database.

    #. What are the steps involved in Database Shutdown ?
    Close the Database, Dismount the Database and Shutdown the Instance.

    #. What is Restricted Mode of Instance Startup ?
    An instance can be started in (or later altered to be in) restricted mode so that when the database is open connections are limited only to those whose user accounts have been granted the RESTRICTED SESSION system privilege.

    ReplyDelete
  14. #. What are the different modes of mounting a Database with the Parallel Server ?
    Exclusive Mode If the first instance that mounts a database does so in exclusive mode, only that Instance can mount the database.
    Parallel Mode If the first instance that mounts a database is started in parallel mode, other instances that are started in parallel mode can also mount the database.

    #. What is Full Backup ?
    A full backup is an operating system backup of all data files, on-line redo log files and control file that constitute ORACLE database and the parameter.

    #. Can Full Backup be performed when the database is open ?
    No.

    #. What is Partial Backup ?
    A Partial Backup is any operating system backup short of a full backup, taken while the database is open or shut down.

    #.WhatisOn-lineRedoLog?
    The On-line Redo Log is a set of tow or more on-line redo files that record all committed changes made to the database.
    Whenever a transaction is committed, the corresponding redo entries temporarily stores in redo log buffers of the SGA are written to an on-line redo log file by the background process LGWR. The on-line redo log files are used in cyclical fashion.

    #. What is Mirrored on-line Redo Log ?
    A mirrored on-line redo log consists of copies of on-line redo log files physically located on separate disks, changes made to one member of the group are made to all members.

    #. What is Archived Redo Log ?
    Archived Redo Log consists of Redo Log files that have archived before being reused.

    #. What are the advantages of operating a database in ARCHIVELOG mode over operating it in NO

    ARCHIVELOG mode ?
    Complete database recovery from disk failure is possible only in ARCHIVELOG mode.
    Online database backup is possible only in ARCHIVELOG mode.

    #. What is Log Switch ?
    The point at which ORACLE ends writing to one online redo log file and begins writing to another is called a log switch.
    #. What are the steps involved in Instance Recovery ?
    R_olling forward to recover data that has not been recorded in data files, yet has been recorded in the on-line redo log, including the contents of rollback segments.
    Rolling back transactions that have been explicitly rolled back or have not been committed as indicated by the rollback segments regenerated in step a.
    Releasing any resources (locks) held by transactions in process at the time of the failure.
    Resolving any pending distributed transactions undergoing a two-phase commit at the time of the instance failure.
    #. What is a Database instance ? Explain
    A database instance (Server) is a set of memory structure and background processes that access a set of database files.
    The process can be shared by all users.
    The memory structure that are used to store most queried data from database. This helps up to improve database performance by decreasing the amount of I/O performed against data file.

    #. What is Parallel Server ?
    Multiple instances accessing the same database (Only In Multi-CPU environments)

    #. What is a Schema ?
    The set of objects owned by user account is called the schema.

    #. What is an Index ? How it is implemented in Oracle Database ?
    An index is a database structure used by the server to have direct access of a row in a table.
    An index is automatically created when a unique of primary key constraint clause is specified in create table comman

    #. What is clusters ?
    Group of tables physically stored together because they share common columns and are often used together is called Cluster

    #. What is a cluster Key ?
    The related columns of the tables are called the cluster key. The cluster key is indexed using a cluster index and its value is stored only once for multiple tables in the cluster.

    #. What is a Shared SQL pool ?
    The data dictionary cache is stored in an area in SGA called the Shared SQL Pool. This will allow sharing of parsed SQL statements among concurrent users.

    #. What is mean by Program Global Area (PGA) ?
    It is area in memory that is used by a Single Oracle User Process.

    ReplyDelete
  15. #. What is a data segment ?
    Data segment are the physical areas within a database block in which the data associated with tables and clusters are stored.

    #. What are the factors causing the reparsing of SQL statements in SGA?
    Due to insufficient Shared SQL pool size.
    Monitor the ratio of the reloads takes place while executing SQL statements. If the ratio is greater than 1 then increase the SHARED_POOL_SIZE.

    #. What is Database Buffers ?
    Database buffers are cache in the SGA used to hold the data blocks that are read from the data segments in the database such as tables, indexes and clusters DB_BLOCK_BUFFERS parameter in INIT.ORA decides the size.

    #. What is dictionary cache ?
    Dictionary cache is information about the databse objects stored in a data dictionary table.

    #. What is meant by recursive hints ?
    Number of times processes repeatedly query the dictionary table is called recursive hints. It is due to the data dictionary cache is too small. By increasing the SHARED_POOL_SIZE parameter we can optimize the size of Data Dictionary Cache.

    # What is meant by redo log buffer ?
    Change made to entries are written to the on-line redo log files. So that they can be used in roll forward operations during database recoveries. Before writing them into the redo log files, they will first brought to redo log buffers in SGA and LGWR will write into files frequently.
    LOG_BUFFER parameter will decide the size.

    #. How will you swap objects into a different table space for an existing database ?
    Export the user Perform import using the command imp system/manager file=export.dmp indexfile=newrite.sql. This will create all definitions into newfile.sql.
    Drop necessary objects.
    Run the script newfile.sql after altering the tablespaces.
    Import from the backup for the necessary objects.

    #. What is the OPTIMAL parameter ?
    It is used to set the optimal length of a rollback segment.

    #. What is the functionality of SYSTEM table space ?
    To manage the database level transactions such as modifications of the data dictionary table that record information about the free space usage.

    #What is a Control file ?
    Database's overall physical architecture is maintained in a file called control file. It will be used to maintain internal consistency and guide recovery operations. Multiple copies of control files are advisable.

    #. How to implement the multiple control files for an existing database ?
    Shutdown the databse
    Copy one of the existing control file to new location
    Edit Config ora file by adding new control file.name
    Restart the database.

    #What is user Account in Oracle database ?
    An user account is not a physical structure in Database but it is having important relationship to the objects in the database and will be having certain privileges.

    #. How will you enforce security using stored procedures ?
    Don't grant user access directly to tables within the application.
    Instead grant the ability to access the procedures that access the tables.
    When procedure executed it will execute the privilege of procedures owner. Users cannot access tables except via the procedure.

    #. What are the dictionary tables used to monitor a database spaces ?
    DBA_FREE_SPACE
    DBA_SEGMENTS
    DBA_DATA_FILES..

    #What are the roles and user accounts created automatically with the database ?
    DBA - role Contains all database system privileges.
    SYS user account - The DBA role will be assigned to this account. All of the basetables and views for the database's dictionary are store in this schema and are manipulated only by ORACLE.
    SYSTEM user account - It has all the system privileges for the database and additional tables and views that display administrative information and internal tables and views used by oracle tools are created using this username.

    ReplyDelete
  16. #. What are the database administrators utilities available ?
    SQL * DBA - This allows DBA to monitor and control an ORACLE database.
    SQL * Loader - It loads data from standard operating system files (Flat files) into ORACLE database tables.
    Export (EXP) and Import (imp) utilities allow you to move existing data in ORACLE format to and from ORACLE database.
    #. What are the minimum parameters should exist in the parameter file (init.ora) ?
    DB NAME - Must set to a text string of no more than 8 characters and it will be stored inside the datafiles, redo log files and control files and control file while database creation.
    DB_DOMAIN - It is string that specifies the network domain where the database is created. The global database name is identified by setting these parameters (DB_NAME & DB_DOMAIN)
    CONTORL FILES - List of control filenames of the database. If name is not mentioned then default name will be used.
    DB_BLOCK_BUFFERS - To determine the no of buffers in the buffer cache in SGA.
    PROCESSES - To determine number of operating system processes that can be connected to ORACLE concurrently.
    The value should be 5 (background process) and additional 1 for each user.
    ROLLBACK_SEGMENTS - List of rollback segments an ORACLE instance acquires at database startup.
    Also optionally LICENSE_MAX_SESSIONS,LICENSE_SESSION_WARNING and LICENSE_MAX_USERS.

    #. What is a trace file and how is it created ?
    Each server and background process can write an associated trace file. When an internal error is detected by a process or user process, it dumps information about the error to its trace. This can be used for tuning the database

    #What are roles ? How can we implement roles ?
    Roles are the easiest way to grant and manage common privileges needed by different groups of database users.
    Creating roles and assigning provies to roles.
    Assign each role to group of users. This will simplify the job of assigning privileges to individual users.

    #What are the different methods of backing up oracle database ?
    - Logical Backups
    - Cold Backups
    - Hot Backups (Archive log)

    #. What is a logical backup ?
    Logical backup involves reading a set of database records and writing them into a file. Export utility is used for taking backup and Import utility is used to recover from backup.

    #. What is cold backup ? What are the elements of it ?
    Cold backup is taking backup of all physical files after normal shutdown of database. We need to take.
    - All Data files.
    - All Control files.
    - All on-line redo log files.
    - The init.ora file (Optional)

    #. What are the different kind of export backups ?
    Full back - Complete database
    Incremental - Only affected tables from last incremental date/full backup date.
    Cumulative backup - Only affected table from the last cumulative date/full backup date.

    #. What is hot backup and how it can be taken ?
    Taking backup of archive log files when database is open. For this the ARCHIVELOG mode should be enabled. The following files need to be backed up.
    All data files. All Archive log, redo log files. All control files.

    #. What is the use of FILE option in EXP command ?
    To give the export file name.

    #. What is the use of COMPRESS option in EXP command ?
    Flag to indicate whether export should compress fragmented segments into single extents.

    #. What is the use of GRANT option in EXP command ?
    A flag to indicate whether grants on database objects will be exported or not. Value is 'Y' or 'N'.

    ReplyDelete
  17. #. What is the use of INDEXES option in EXP command ?
    A flag to indicate whether indexes on tables will be exported.

    #. What is the use of ROWS option in EXP command ?
    Flag to indicate whether table rows should be exported. If 'N' only DDL statements for the database objects will be created.

    #. What is the use of CONSTRAINTS option in EXP command ?
    A flag to indicate whether constraints on table need to be exported.

    #. What is the use of FULL option in EXP command ?
    A flag to indicate whether full database export should be performed.

    #. What is the use of OWNER option in EXP command ?
    List of table accounts should be exported.

    #. What is the use of TABLES option in EXP command ?
    List of tables should be exported.
    #. What is the use of RECORD LENGTH option in EXP command ?
    Record length in bytes.

    #. What is the use of INCTYPE option in EXP command ?
    Type export should be performed COMPLETE,CUMULATIVE,INCREMENTAL.

    #. What is the use of RECORD option in EXP command ?
    For Incremental exports, the flag indirects whether a record will be stores data dictionary tables recording the export.

    #. What is the use of PARFILE option in EXP command ?
    Name of the parameter file to be passed for export.

    #. What is the use of PARFILE option in EXP command ?
    Name of the parameter file to be passed for export.

    #. What is the use of ANALYSE ( Ver 7) option in EXP command ?
    A flag to indicate whether statistical information about the exported objects should be written to export dump file.

    #. What is the use of CONSISTENT (Ver 7) option in EXP command ?
    A flag to indicate whether a read consistent version of all the exported objects should be maintained.

    #. What is use of LOG (Ver 7) option in EXP command ?
    The name of the file which log of the export will be written.

    #.What is the use of FILE option in IMP command?
    The name of the file from which import should be performed.

    #. What is the use of SHOW option in IMP command ?
    A flag to indicate whether file content should be displayed or not.

    #. What is the use of IGNORE option in IMP command ?
    A flag to indicate whether the import should ignore errors encounter when issuing CREATE commands.

    #. What is the use of GRANT option in IMP command ?
    A flag to indicate whether grants on database objects will be imported.

    #. What is the use of INDEXES option in IMP command ?
    A flag to indicate whether import should import index on tables or not.

    ReplyDelete
  18. #. What is the use of ROWS option in IMP command ?
    A flag to indicate whether rows should be imported. If this is set to 'N' then only DDL for database objects will be executed.

    #. What are the data types allowed in a table ?
    CHAR,VARCHAR2,NUMBER,DATE,RAW,LONG and LONG RAW.

    # What is difference between CHAR and VARCHAR2 ? What is the maximum SIZE allowed for each type ?
    CHAR pads blank spaces to the maximum length. VARCHAR2 does not pad blank spaces. For CHAR it is 255 and 2000 for VARCHAR2

    #What is CYCLE/NO CYCLE in a Sequence ?
    CYCLE specifies that the sequence continues to generate values after reaching either maximum or minimum value. After pan ascending sequence reaches its maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum.
    NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value.

    #. What are the advantages of VIEW ?
    To protect some of the columns of a table from other users.
    To hide complexity of a query.
    To hide complexity of calculations.

    #Can a view be updated/inserted/deleted? If Yes under what conditions ?
    A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or more tables then insert, update and delete is not possible.

    #.If a View on a single base table is manipulated will the changes be reflected on the base table?
    If changes are made to the tables which are base tables of a view will the changes be reference on the view.

    # What is a Package Procedure ?
    A Package procedure is built in PL/SQL procedure.
    What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
    % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
    The advantages are : I. Need not know about variable's data type
    ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.

    #. What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different
    table or views and variables.
    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type);
    e_rec emp% ROWTYPE
    cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.

    #. What is PL/SQL table ?
    Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.

    #. What is a cursor ? Why Cursor is required ?
    Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.

    #Explain the two type of Cursors ?
    There are two types of cursors, Implicit Cursor and Explicit Cursor.
    PL/SQL uses Implicit Cursors for queries.
    User defined cursors are called Explicit Cursors. They can be declared and used.

    ReplyDelete
  19. # What are the PL/SQL Statements used in cursor processing ?
    DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.

    #. What are the cursor attributes used in PL/SQL ?
    %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows fetched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are fetched.
    % NOT FOUND - to check whether cursor has fetched any row. True if no rows are fetched.
    These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.

    #. What is a cursor for loop ?
    Cursor for loop implicitly declares %ROWTYPE as loop index, opens a cursor, fetches rows of values from active set into fields in the record and closeswhen all the records have been processed.
    eg. FOR emp_rec IN C1 LOOP
    salary_total := salary_total +emp_rec sal;
    END LOOP;

    #. What will happen after commit statement ?
    Cursor C1 is
    Select empno,
    ename from emp;
    Begin
    open C1; loop
    Fetch C1 into
    eno.ename;
    Exit When
    C1 %notfound;-----
    commit;
    end loop;
    end;

    # The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
    The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.

    #. Explain the usage of WHERE CURRENT OF clause in cursors ?
    WHERE CURRENT OF clause in an UPDATE, DELETE statement refers to the latest row fetched from a cursor.

    #. What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.

    #. How many types of database triggers can be specified on a table ? What are they ?
    Insert Update Delete
    Before Row o.k. o.k. o.k.
    After Row o.k. o.k. o.k.
    Before Statement o.k. o.k. o.k.
    After Statement o.k. o.k. o.k.
    If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
    If WHEN clause is specified, the trigger fires according to the returned boolean value.

    ReplyDelete
  20. #. Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why ?
    It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.

    # What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.

    #. What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
    Mutation of table occurs.

    #. Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
    ii. done using Integrity Constraints.
    I & ii.

    #. What is an Exception ? What are types of Exception ?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user_defined. Some of Predefined

    exceptions are.
    CURSOR_ALREADY_OPEN
    DUP_VAL_ON_INDEX
    NO_DATA_FOUND
    TOO_MANY_ROWS
    INVALID_CURSOR
    INVALID_NUMBER
    LOGON_DENIED
    NOT_LOGGED_ON
    PROGRAM-ERROR
    STORAGE_ERROR
    TIMEOUT_ON_RESOURCE
    VALUE_ERROR
    ZERO_DIVIDE
    OTHERS.

    #. What is Pragma EXECPTION_INIT ? Explain the usage ?
    The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
    e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)

    #. What is Raise_application_error ?
    Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.

    #. What are the return values of functions SQLCODE and SQLERRM ?
    SQLCODE returns the latest code of the error that has occurred.
    SQLERRM returns the relevant error message of the SQLCODE.

    #. Where the Pre_defined_exceptions are stored ?
    In the standard package.

    #. What is a stored procedure ?
    A stored procedure is a sequence of statements that perform specific function.

    #. What is difference between a PROCEDURE & FUNCTION ?
    A FUNCTION always returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.

    #. What are advantages fo Stored Procedures /
    Extensibility, Modularity, Reusability, Maintainability and one time compilation.

    #. What are the modes of parameters that can be passed to a procedure ?
    IN, OUT, IN-OUT parameters.

    #. What are the two parts of a procedure ?
    Procedure Specification and Procedure Body.

    ReplyDelete
  21. #. Give the structure of the procedure ?
    PROCEDURE name (parameter list.....)
    is
    local variable declarations
    BEGIN
    Executable statements.
    Exception.
    exception handlers
    end;

    #. Give the structure of the function ?
    FUNCTION name (argument list .....) Return datatype is
    local variable declarations
    Begin
    executable statements
    Exception
    execution handlers
    End;

    #. Explain how procedures and functions are called in a PL/SQL block ?
    Function is called as part of an expression.
    sal := calculate_sal ('a822');
    procedure is called as a PL/SQL statement
    calculate_bonus ('A822');

    #. What is Overloading of procedures ?
    The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.
    e.g. DBMS_OUTPUT put_line

    #. What is a package ? What are the advantages of packages ?
    Package is a database object that groups logically related procedures.
    The advantages of packages are Modularity, Easier Application Design, Information. Hiding,. reusability and Better Performance.

    #.What are two parts of package ?
    The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
    Package Specification contains declarations that are global to the packages and local to the schema.
    Package Body contains actual procedures and local declaration of the procedures and cursor declarations.

    #. What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
    A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.

    #. How packaged procedures and functions are called from the following?
    a. Stored procedure or anonymous block
    b. an application program such a PRC *C, PRO* COBOL
    c. SQL *PLUS
    a. PACKAGE NAME.PROCEDURE NAME (parameters);
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    EXEC SQL EXECUTE
    b.
    BEGIN
    PACKAGE NAME.PROCEDURE NAME (parameters)
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    END;
    END EXEC;
    c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any out/in-out parameters. A function can not be called.

    #. Name the tables where characteristics of Package, procedure and functions are stored ?
    User_objects, User_Source and User_error.

    #. What are the different types of Package Procedure ?
    1. Restricted package procedure.
    2. Unrestricted package procedure.

    #. What is the difference between restricted and unrestricted package procedure ?
    Restricted package procedure that affects the basic basic functions of SQL * Forms. It cannot used in all triggers except key triggers.
    Unrestricted package procedure that does not interfere with the basic functions of SQL * Forms it can be used in any triggers

    ReplyDelete
  22. #What is PL/SQL ?
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.

    #. What is the basic structure of PL/SQL ?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.

    #. What are the components of a PL/SQL block ?
    A set of related declarations and procedural statements is called block.

    #. What are the components of a PL/SQL Block ?
    Declarative part, Executable part and Exception part.
    Datatypes PL/SQL

    #. What are the datatypes a available in PL/SQL?
    Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
    Some composite data types such as RECORD & TABLE.

    ReplyDelete
  23. ORACLE UNINSTALL:
    The simplest way to remove Oracle is to run the Oracle installer:
    Start > Programs > Oracle Installation Products > Universal Installer
    1.On the first screen click on "Deinstall Products..."
    2.Expand the tree view (just so that the second level is visible) and make sure you select everything that is selectable.
    3.Click on "Remove..."
    4.On the confirmation screen click "Yes"
    5.When it has finished click "Close" and then "Exit" to quit the installer
    Whilst the Oracle installer removes many components there are a number of things that it leaves behind. In order to completely remove all traces of Oracle the following additional steps will need to be taken:
    i.Stop any Oracle services that have been left running. (Start > Settings > Control Panel > Services.)
    Services which I have found left behind are 'OracleOraHome90TNSListener' and 'OracleServiceORACLE'. However there may be others depending on your installation. Look for any services with names starting with 'Oracle'.
    ii.Run regedit (Start > Run > Enter "regedit", click "Ok"), find and delete the following keys:
    HKEY_LOCAL_MACHINE
    \SOFTWARE
    \ORACLE

    HKEY_LOCAL_MACHINE
    \SYSTEM
    \CurrentControlSet
    \Services
    \EventLog
    \Application
    \Oracle.oracle
    Note: I have had it reported that some people also have registry entries saved under HKEY_CURRENT_USER\SOFTWARE\ORACLE, this registry entry may be created by some Oracle utilities. If it exists then delete it.
    iii. Delete the Oracle home directory:
    "C:\Oracle"
    This will also remove your database files (unless you located them elsewhere, in which case you will need to delete them separately).
    iv. Delete the Oracle program Files directory:
    "C:\Program Files\Oracle"
    v. Delete the Oracle programs profile directory:
    "C:\Documents and Settings\All Users\Start Menu\Programs\Oracle - OraHome90"
    if you did not first run the Oracle installer to remove Oracle then there may be other Oracle profile group directories to remove.
    vi. Some of the Oracle services may be left behind by the uninstall. Open ‘services’ on the control panel, make a note of which Oracle services remain and see the notes ‘How to remove a service’ to remove them.
    vii. If you didn't first run the Oracle Installer to remove Oracle then you may have some references to Oracle left in the path. To remove these: Start > Settings > Control Panel > System > Advanced > Environment Variables, look at both the use and system variable 'PATH' and edit them to remove any references to Oracle

    ReplyDelete
  24. ORACLE LOG-IN as DBA

    # TO login as a user SYSDBA is having all the rights:-.
    On cmd prompt "sqlplus /nolog" --> SQL> Connect / AS SYSDBA
    # IF connection is fail with error message "ORA-01031: insufficient privileges" then please take in consider the following points
    1) The OS logged in user should have administrator & ORA_DBA privileges on that system.
    2) User right is defined in the Default Domain Controller Group Policy object (GPO).If your db is one windows then do the following.
    Go to "Control Panel" -> "Admin Tools" -> "Local Security Policy." Within "Local Policies", go to “User Right Assignment." Add the OS user to "Logon as a Batch Job."
    3). Need to is check Set SQLNET.AUTHENTICATION_SERVICES= (NTS) is commented in the sqlnet.ora file.
    2) C:\Documents and Settings\sacgai>set oracle_sid=instance_name
    C:\Documents and Settings\sacgai>set local_sid=instance_name
    C:\Documents and Settings\sacgai>sqlplus/nolog
    SQL*Plus: Release 9.2.0.1.0 - Production on Tue Jun 16 14:44:08 2009
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    SQL> conn /as sysdba
    Connected.
    # Displayed all users created in Database
    SQL> select * from all_users;
    # Grant has to be given to new DBA user is ;
    SQL>grant connect, resource, dba, sysdba to dbmon;
    ## To switch to any other user
    SQL> connect system;
    fallowed by password

    ReplyDelete
  25. ORACLE CREATE USER
    # There are three types of USER in Oracle
    # Local users :- A local user needs a password to log on to the database.
    SQL> create user alfredo identified by alfredos_secret;
    # External users :- An external user, unlike a local user, doesn't need a password to log on to the database, instead, an external service (such as the operating system) authenticates the user when (s)he logs on the database.
    SQL> create user alfredo identified externally;
    # Global users :- A global user, like an external user, doesn't need a password to log on to the database, instead, (s)he is authenticated by an enterprise directory service (such as X.509).
    # create user alfredo identified globally as 'external_name';

    PRIVILEGES:-
    NOTE: Once the user is created on DB, still that user is not able to login to DB as session privilege is not granted and query to grant the session privilege is "create session"
    NOTE:When a user is created, the role public is automatically assigned to this user. However, the role is not visible in dba_sys_privs nor session_roles.
    # In Oracle, there are two types of privileges: system privileges and object privileges.
    system privileges : create session, drop user, alter database Object privileges: select, insert, update, delete, alter, debug, flashback, on commit refresh, query rewrite, references, all
    # To create the TableSpace
    SQL> create tablespace ravan datafile 'D:\oracle\oradata\apple\ravan.dbf' size 5m;
    # Create a user with full rights to create objects and save data:
    SQL> CREATE USER MySchemaOwner IDENTIFIED BY Change This DEFAULT TABLESPACE system TEMPORARY TABLESPACE temp QUOTA UNLIMITED ON system;
    SQL> CREATE ROLE conn;
    SQL> GRANT CREATE session, CREATE table, CREATE view, CREATE procedure,CREATE synonym, ALTER table, ALTER view, ALTER procedure,ALTER synonym,DROP table, DROP view, DROP procedure,DROP synonym, TO conn;
    SQL> GRANT conn TO MySchemaOwner;
    # Displayed Table Space, language, Territory details:-
    SQL> SELECT * from database_properties WHERE property_name ='DEFAULT_PERMANENT_TABLESPACE';

    #What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?
    A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database.
    # Name a tablespace automatically created when you create a database.
    The SYSTEM tablespace.
    # User tablespace: Used to store user data. A database can consists of one or more of such permanent tablespaces.
    • Temporary tablespace: Used to stored temporary data generated during regular database operations. Once again, a database can have one or more of these temporary tablespaces.
    • Undo tablespace: Undo tablespaces are used to stored the undo data generated by the Oracle Database for transaction rollback and read consistency purposes. A database contains one undo tablespace per instance.
    • SYSTEM Tablespace: There is one SYSTEM tablespace per database. It is permanent in content type and contains database dictionary information vital for the functioning of the database.
    # All created TableSpace is present in v$tablespace table of Oracle.
    SQL> select * from v$tablespace;
    # How would you determine who has added a row to a table?
    Turn on fine grain auditing for the table.

    ReplyDelete
  26. ORACLE Locked Users:-
    # A user can be created locked, that is, the user cannot connect to the database.
    SQL> create user alfredo identified by passw0rd account lock;
    # The user is now created, he can be granted some rights, for example the right to connect to the database:
    SQL> grant connect to alfredo;
    # Now, if the user tries to connect to the database, he will get ORA-28000:
    SQL> connect alfredo/passw0rd
    ERROR: ORA-28000: the account is locked
    # The user can now be unlocked with an alter user statement:
    SQL> alter user alfredo account unlock;
    # Which allows Alfredo to log on to the database now:
    SQL> connect alfredo/passw0rd
    Connected.

    Expiring password:-
    # A user can be created such that he needs to change his password when he logs on. This is achieved with the password expire option.
    SQL> create user dilbert identified by tie password expire;
    # Now, Dilbert connecting:
    SQL> connect dilbert/tie
    ERROR: ORA-28001: the password has expired
    # Display the current user:-
    SQL> select user from user_users; or show user;
    # You can see the name of that database by executing
    SQL>select name from v$database;

    ReplyDelete
  27. ORACLE Constraints
    # How to Add composite key(more than one primary key in single table):-
    SQL> create table alm (ALL_COD varchar2(7),DAT_CAM date,primary key (all_cod,dat_cam),CAR_CEL number);
    # SUM(date),AVG(date) these are invalid fuctions.And group function like SUM(), AVG() etc should not declared in Where clause.
    # Constraint (Primary key) in already exiting table :
    SQL>ALTER TABLE emp ADD CONSTRAINT emp_pk PRIMARY KEY (emp_id);
    # Constraint (Foreigen key) in already exiting table :
    SQL> ALTER TABLE emp1 ADD CONSTRAINT emp_ID FOREGIN KEY (emp_ID) REFERNCE emp (emp_ID);
    # Drop Constraint
    SQL> alter table alm drop primary key;

    ReplyDelete
  28. SOME GOOD PRACTICES on Oracle
    # Rename the table name.
    SQL> Raname table to table1;
    # Rename the colomn name of table
    SQL> alter table sales rename column order_date to date_of_order;
    # To convert the number field into char.
    select to_char(to_date(17777,'J'),'JSP') from dual;
    # To retrieve the current date
    SQL>SELECT TO_CHAR(SYSDATE,'year') FROM DUAL;
    #Oracle allows the assignment of special escape characters to the reserved characters in Oracle can be escaped to normal characters that is interpreted literally, by using ESCAPE keyword.
    SQL>SELECT guest_name FROM guest_table WHERE name LIKE ‘% sa\_%’ ESCAPE ‘\’;
    # Merge command to merge the data.
    SQL>merge into new_employee a
    /* when merge command is used then changes is happened on only new_employee table not in the employee table*/
    2 using employee b on (a.employee_id=b.employee_id) When Matched Then
    update set a.name=b.first_name||','||last_name When Not Matched Then Insert values (b.employee_id,b.first_name);
    # Displayed the date in following format:
    SQL> select to_char(to_date('19-mar-2008','DD-MM-YYYY'),'fmddspth "of"month yyyy
    fmhh:mi:ss am') newdate from dual;

    NEWDATE
    -------------------------------------------
    nineteenth ofmarch 2008 12:00:00 am

    SQL> select to_char(to_date('19-mar-2008','DD-MM-YYYY'),'fmddspth "of"month yyyy
    hh:mi:ss am') newdate from dual;

    NEWDATE
    -------------------------------------------
    nineteenth ofmarch 2008 12:0:0 am

    # # The Trunc function returns a number truncated to a certain number of decimal places.
    Syntax :- trunc( number, [ decimal_places ] )
    SQL> trunc(125.815) would return 125
    SQL> trunc(125.815, 2) would return 125.81
    SQL> trunc(125.815, -1) would return 120
    SQL> trunc(125.815, -2) would return 100
    SQL> trunc(125.815, -3) would return 0
    # # The Round function :
    SQL> select round( 7.7777),
    round( 7.7777, 3),
    round( 3.3333, 2),
    round(-3.3333, 2),
    round(-7.7777, 1)
    from dual;

    ROUND(7.7777) ROUND(7.7777,3) ROUND(3.3333,2) ROUND(-3.3333,2) ROUND(-7.7777,1)
    ------------- --------------- --------------- ---------------- ----------------
    8 7.778 3.33 -3.33 -7.8

    ## SUBSTR function is working as
    SQL> select substr('Helo world',2,1) from dual;
    S
    -
    e
    SQL> select substr('Helo world',1,1) from dual;
    S
    -
    H
    SQL> select substr('sachin',4) from dual;

    SUB
    ---
    hin
    SQL> select substr('sachin',-1) from dual;
    S
    -
    n
    #Start counting from last character and displayed the remaining sentence.
    SQL> select substr('sachin',-1,1) from dual;
    S
    -
    n
    SQL> select substr('sachin',-2,1) from dual;
    S
    -
    i
    SQL> select substr('sachin',-2) from dual;
    S
    -
    in
    ## TRIM function is working as
    SQL> select trim('H'from 'Helo world') from dual;

    TRIM('H'F
    ---------
    elo world
    SQL> select trim('h'from 'Helo world') from dual;
    TRIM('H'FR
    ----------
    Helo world

    ReplyDelete
  29. # To calculate the nth (ie on run time declare the highest value) highest sal from the table
    SQL>select distinct(a.sal) from emp1 a where &n=(select count(distinct(b.sal)) from emp1 b where a.sal < b.sal);

    ReplyDelete