This document provides an introduction to selecting data from database tables in SQL. It discusses running SQL scripts, what a database table is, the basic SELECT statement syntax to retrieve data from a table including columns, filters, grouping and having. It also covers data types, primary keys, column aliases, and unlocking other user schemas.
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Oracle SQL - Select Part -1 let's write some queries!
1. 3. Select part-1 : Getting started
• Revisit connections and scripts
• First Select ( and what is a table?! )
• All columns or some columns
• Data Types
• Aliases
• Primary keys
http://adata.guru
3. What is a table?
One of the basic database object types
http://adata.guru
14 Rows
8 Columns
4. Select statement
Used to “read”data from the database
**No changes are being made to the data
Select [* | column_list ]
From <table_name>
Where <filter_conditions>
Group by <group columns>
Having <filters on groups>
http://adata.guru
5. Wild card v/s columns
http://adata.guru
* all columns Specific columns
Structure (shift+f4)
6. Data types
Describe what kind of data a column has.
http://adata.guru
Column Name Datatype (length/precision)
7. List of Oracle Data types
http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#i16209
• Character
– char (fixed length string) eg. Char(10) – “Hello “
– varchar2( variable length string) eg. Varchar2(10) – “Hello”
– and more…
• Numeric
– Number. Eg 123.50
– and more..
• Date
– Date eg. 15-aug-1947 00:02:00 AM (includes time component)
– Timestamp eg. 15-aug-1947 00:02:00.155 AM
• and more…
http://adata.guru
8. Primary Key
• Uniquely identifies the row in a table.
Check the constraints section in the table definition.
http://adata.guru
Use SHIFT+F4
shortcut key for
SQL Developer and
F4 if you are using
Toad.
9. (column) Aliases
• More readable, meaningful and useful column headers.
• Very useful when dealing with complex names or
generating reports
http://adata.guru
10. (column) Aliases
• Useful when you want contextual and meaningful names
This kind of join is called a self-join where we join a table (emp) with itself. We’ll cover this
in more detail in the JOINS Chapter.
http://adata.guru
Same column
different heading
based on
context/meaning
11. Unlocking other schemas
List of user account present in the database
Conn / as sysdba
Select username from dba_users
Demo Accounts : http://docs.oracle.com/cd/E11882_01/server.112/e10831/installation.htm
Unlocking acccounts:
Conn / as sysdba
Alter user hr identified by “hr”;
Alter user oe identified by “oe”;
Alter user pm identified by “pm”;
Alter user sh identified by “sh”;
Alter user ix identified by “ix”;
http://adata.guru