Monday, October 24, 2011

DBMS AND SQL COMMANDS BY LOKRE

DBMS – DATA BASE MANAGEMENT SYSTEM.

RDBMS -- RELATIONAL DBMS.


DATA --- Collection of Files.

Files  .txt (Notepad)
.doc (Ms-Word)
.ppt (Ms- PowerPoint)
.xls (Ms- Excel)
.pdf (Acrobat)

And some more example you can find in the below links for file extensions

http://www.fileinfo.com/filetypes/common

http://en.wikipedia.org/wiki/List_of_file_formats



DATA BASE:


Logical container to store the data in the form of tables, objects & Procedures, functions etc.









ODBC  Open Data base Connectivity.



2- Tier Architecture :



FRONT END ODBC BACK END
Java, .Net (Developers) DATABASE
(SQL, MYSQL, DB2, SYBASE, FOXPRO)

Database Developers





It is named as 2-Tier Architecture because it has Front end and Back end.


Example:

Front End -- >> Gmail’s Home page (User Interface page)
Back End -- > > Data stored here (Your emails and data files, attachments etc)


If you’re using java, then it’s JDBC connectivity.
ADO. NET connectivity is for DOT NET.






3 – Tier Architecture:



APPLICATION SOFTWARE
|
|

FRONT END ODBC BACK END
(Developers) DATABASE
(SQL, MYSQL, DB2, SYBASE, FOXPRO)

Database Developers


It is named as 3-Tier Architecture because it has
Application Software, Front end and Back end.


APPLICATION SOFTWARE:

Application software, also known as an application or an "app", is computer softwaredesigned to help the user to perform specific tasks. Examples include enterprise software, accounting software, office suites, graphics software and media players. Many application programs deal principally with documents. Apps may be bundled with the computer and its system software, or may be published separately. Some users are satisfied with the bundled apps and need never install one.




4 – Tier Architecture:



APPLICATION SOFTWARE
(Desktop Applications)
|
|

FRONT END ODBC BACK END
(Developers) DATABASE
(SQL, MYSQL, DB2, SYBASE, FOXPRO)
|
| Database Developers
Web Browser
(ASP. NET, PHP)


It is named as 4-Tier Architecture because it has
Application Software, Front end, Back end and Web Browser.










DATABASE MANAGEMENT SYSTEM (DBMS)

There are 3- types of DBMS:

HDBMS -- Hierarchal DBMS
NDBMS -- Network ’’
RDBMS -- Relational ’’

RDBMS -- 12 Rules (E F CODD RULES (Edgar F. Codd Rules)).

http://en.wikipedia.org/wiki/Types_of_DBMS

RDBMS ----

ORACLE – PL/SQL -- 80% Market (Platform Independent) -12 EF Codd Rules
SQL SERVER -- 20% market
MS ACCESS
MY SQL --
DB2
SYBASE
FOXPRO
PORT GRE SQL







Oracle PL/SQL follows 12 EF codd Rules.

http://en.wikipedia.org/wiki/Codd's_12_rules

DB2, FOXPRO, PORT GRE SQL follows only 4/5 E F CODD RULES.


Platform Independent: Application that works on any platform (UNIX, Linux, MAC and Windows).



GUI – GRAPHICAL USER INTERFACE (Windows 7/XP)


NOT GUI – Eg) Command prompt.



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

DDL

DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database.

Examples: CREATE, ALTER, DROP statements

DCL

DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.

Examples: GRANT, REVOKE statements

TCL


TCL is abbreviation of Transactional Control Language. It is used to manage different transactions occurring within a database.

Examples: COMMIT, ROLLBACK statements

DML


DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database.

Examples: SELECT, UPDATE, INSERT statements


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



DATA DEFINITION LANGUAGE (DDL)

CREATING A TABLE

Create table tablename
(
Column 1 data type (Size),
Column 2 data type (Size),
);


ALTERING THE TABLE

1. ALTER TABLE tablename ADD (Colname datatype (size), colname datatype (size));
2. ALTER TABLE tablename DROP (Colname datatype (size), colname datatype (size));
3. ALTER TABLE tablename RENAME Column old name TO new name;

MODIFY THE TABLE

ALTER TABLE tablename MODIFY (Column datatype (size));

DROPING THE TABLE

DROP TABLE tablename;

RENAMING THE TABLE

RENAME oldtable TO newtable;


TRUNCATE THE TABLE-Data will be completly

TRUNCATE TABLE tablename;




DESCRIBE

DESC tablename;


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


DATA MANIPULATION LANGUAGE (DML)


INSERTING THE DATA IN A TABLE

To insert records sequentially

INSERT INTO tablename VALUES (Val1, Val2, Val3…);

To insert records randomly

INSERT INTO tablename (Column1, Column2, Column3….) VALUES (Val1, Val2, Val3…)

To insert Multiple Records (Sequentially and Randomly)

INSERT INTO TABLENAME VALUE (&CID,'&CUSTNAME','&BRANCH', ‘&BRANCHID,'&CDOB');

UPDATING THE DATA IN A TABLE

UPDATE tablename SET Colname= value WHERE condition;

Eg)
UPDATE employee SET name= ‘SUNEETHA’ WHERE name=’SUNITHA’;

UPDATE banking SET CUSTNAME= ‘ARIGI’ WHERE CUSTNAME= ’suneetha’; (ERROR)

IN SQL, We can’t update and Insert a query at a time. But, we can do it in PL/SQL if there are many records.


DELETING THE DATA IN TABLE

DELETE FROM tablename WHERE condition;

Eg)

DELETE FROM employee WHERE eno=1;



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

DATA QUERY LANGUAGE (DQL)


SELECT COMMAND -- > To retrieve the data from table.


SELECT * FROM tablename;


To retrieve a selected columns

SELECT Columns FROM tablename WHERE condition;

Eg)

SELECT eno, name, age, salary FROM emp WHERE eno=1;



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


TRANSACTIONAL CONTROL LANGUAGE (TCL)


(Or)

DATA TRANSACT LANGUAGE (DTL)

Syntax:

COMMIT;

Commit command saves all transactions permanently.

Syntax:

ROLLBACK;

To undo transactions.


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




DATA CONTROL LANGUAGE (DCL):

USER CREATION

CREATE USER IDENTIFIED BY ;
Eg)
CREATE USER SUNEETHA IDENTIFIED BY SUNEETHA;


GRANT:

GRANT TO ;

PRIVILEGES - > Connect, resource

Eg) If you want to give permission to user called “TESTER” then, here is the syntax:

GRANT connect, resource to TESTER;



REVOKE

REVOKEFROM;

PRIVILEGES - > Connect, resources

Eg) If you want to take back the permission from user called “TESTER” then, here is the syntax:

REVOKE connect, resource FROM TESTER;

CONNECTING TO DATABASE

1. CONN SUNEETHA/SUNEETHA (SQL PROMPT)
2. USERNAME ---------- (SQL DEVELOPER TOOL)
PASSWORD ----------


DROP THE USER

Drop user USERNAME;
Eg) Drop user SUNEETHA;


---- CONTINUES.......

SQL BASICS BY LOKRE

SQL BASIC QUERIES

SQL>Conn /as sysdba
(Conn Username/Password)


1. SQL>Show user;

USER is SYSTEM

2. SQL>select banner from v$version;

BANNER
----------------------------------------
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 – Production


3. SQL>Select global_name from global_name;

GLOBAL_NAME
XE

4. SQL> Select * from tab;

It displays all the tables from Database.


5. SQL> Select * from all_users;

It shows the list of users.

6. SQL>Clear scr;

It clears the screen.


There are two types of tables in Oracle

1. SYSTEM TABLES (or) DATA DICTIONARY TABLES (or) PREDEFINED TABLES.
2. USER DEFINED TABLES.


SQL – STRUCTURED QUERY LANGUAGE


DDL (Data Definition Language)

CREATE, ALTER, DROP, RENAME, TRUNCATE

DML (DATA MANIPULATION LANGUAGE)

INSERT, UPDATE, DELETE

DQL (DATA QUERY LANGUAGE)

SELECT

TCL (TRANSACTIONAL CONTROL LANGUAGE)

COMMIT, ROLLBACK


DCL (DATA CONTROL LANGUAGE)

GRANT, REVOKE


LINKS TO SQL :

http://st-curriculum.oracle.com/tutorial/SQLDeveloper/index.htm
http://www.vacic.org/lib/sql/
http://beginner-sql-tutorial.com/sql.htm
http://www.w3schools.com/sql/default.asp


PL/SQL
http://www.plsql-tutorial.com/

LOKREs NOTES

BASICS:


DBMS – DATA BASE MANAGEMENT SYSTEM.

RDBMS -- RELATIONAL DBMS


DATA --- Collection of Files.

Files  .txt (Notepad)
.doc(Ms-Word)
.ppt(Ms- PowerPoint)
.xls (Ms- Excel)
.pdf(Acrobat)

And some more example you can find in the below links for file extensions

http://www.fileinfo.com/filetypes/common

http://en.wikipedia.org/wiki/List_of_file_formats



DATA BASE:

Logical container to store the data in the form of tables, objects & Procedures, functions etc.









ODBC  Open Data base Connectivity.



2- Tier Architecture :



FRONT END ODBC BACK END
Java, .Net (Developers) DATABASE
(SQL, MYSQL, DB2, SYBASE, FOXPRO)

Database Developers





It is named as 2-Tier Architecture because it has Front end and Back end.


Example:

Front End -- >> Gmail’s Home page (User Interface page)
Back End -- > > Data stored here (Your emails and data files, attachments etc)


If you’re using java, then it’s JDBC connectivity.
ADO. NET connectivity is for DOT NET.






3 – Tier Architecture:



APPLICATION SOFTWARE
|
|

FRONT END ODBC BACK END
(Developers) DATABASE
(SQL, MYSQL, DB2, SYBASE, FOXPRO)

Database Developers


It is named as 3-Tier Architecture because it has
Application Software, Front end and Back end.


APPLICATION SOFTWARE:

Application software, also known as an application or an "app", is computer softwaredesigned to help the user to perform specific tasks. Examples include enterprise software, accounting software, office suites, graphics software and media players. Many application programs deal principally with documents. Apps may be bundled with the computer and its system software, or may be published separately. Some users are satisfied with the bundled apps and need never install one.




4 – Tier Architecture:



APPLICATION SOFTWARE
(Desktop Applications)
|
|

FRONT END ODBC BACK END
(Developers) DATABASE
(SQL, MYSQL, DB2, SYBASE, FOXPRO)
|
| Database Developers
Web Browser
(ASP. NET, PHP)


It is named as 4-Tier Architecture because it has
Application Software, Front end, Back end and Web Browser.










DATABASE MANAGEMENT SYSTEM (DBMS)

There are 3- types of DBMS:

HDBMS -- Hierarchal DBMS
NDBMS -- Network ’’
RDBMS -- Relational ’’

RDMS -- 12 Rules (E F CODD RULES).

http://en.wikipedia.org/wiki/Types_of_DBMS

RDBMS ----

ORACLE – PL/SQL -- 80% Market (Platform Independent) -12 EF Codd Rules
SQL SERVER -- 20% market
MS ACCESS
MY SQL
DB2
SYBASE
FOXPRO
PORT GRE SQL







Oracle PL/SQL follows 12 EF codd Rules.
http://en.wikipedia.org/wiki/Codd's_12_rules

DB2, FOXPRO, PORT GRE SQL follows only 4/5 E F CODD RULES.


Platform Independent: It works on any platform (UNIX, Linux, and Windows).



GUI – GRAPHICAL USER INTERFACE (Windows 7/XP)


NOT GUI – Command prompt.














ORACLE stands for

OAK RIDGE AUTOMATIC COMPUTER LOGICAL ENGINE.


ORACLE

1. USER.
2. DEVELOPER.
3. ADMIN/ADMINISTRATOR.

USER -- SQL knowledge is enough.
DEVELOPER -- SQL, PL/SQL knowledge is enough.
ADMIN - He should know the following point below:
1. Sql
2. Pl/Sql
3. How to take a backup.
4. Maintenance of data
5. Tuning
6. Restore
7. Replication
8. Data Guard

Replication is the process of sharing information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, fault-tolerance, or accessibility.


Data Guard:

Providing the security to database.








ORACLE FLAVOURS

1. ENTERPRISE EDITION – This is for Companies.
2. EXPRESS EDITION (XE) – This is for STANDALONE (for single users/Single system).
3. STANDARD EDITION – This is for globally.
4. WORK GROUP – This is for Office purpose.


VERSIONS OF ORACLE:

1979 – Version 1
1990 – 6.0 Version
1995 – 7.0
1996 – 7.1
1997 – 7.2
1998 – 8i (‘i’ stands for internet. It is a first internet version and platform independent).

2000 – 9i
2004 –10g (‘g’ stands for GRID COMPUTING).
2007 – 11g


Grid computing is a term referring to the combination of computer resources from multiple administrative domains to reach a common goal.

http://ss64.com/ora/syntax-versions.html