week-1a intro database

Upload: kenan

Post on 30-May-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Week-1a Intro Database

    1/22

    WELCOME TO DBMS

    DATABASE MANAGEMENT SYSTEM

    INSTRUCTOR : KENAN ETNKAYA

    WEEK-1A

  • 8/9/2019 Week-1a Intro Database

    2/22

    What is Database ?

    A database is a collection of informationthat is organized so that it can easily beaccessed, managed, and updated. In oneview, databases can be classified

    according to types of content:bibliographic, full-text, numeric, andimages.

    You can think of a database as anelectronic filing system.

  • 8/9/2019 Week-1a Intro Database

    3/22

    Traditional databases are organized by fields, records, and files.

    A field is a single piece of information;

    A record is one complete set of fields;

    A file is a collection of records.

    For example, a telephone book is

    analogous to a file. It contains a list of

    records, each of which consists of three

    fields: name, address, and telephone

    number.

    http://www.webopedia.com/TERM/d/field.htmlhttp://www.webopedia.com/TERM/d/record.htmlhttp://www.webopedia.com/TERM/d/file.htmlhttp://www.webopedia.com/TERM/d/file.htmlhttp://www.webopedia.com/TERM/d/record.htmlhttp://www.webopedia.com/TERM/d/field.html
  • 8/9/2019 Week-1a Intro Database

    4/22

    TABLE ?

    A table is a set of data elements (values)that is organized using a model ofhorizontal rows and vertical columns

    http://en.wikipedia.org/wiki/Row_%28database%29http://en.wikipedia.org/wiki/Column_%28database%29http://en.wikipedia.org/wiki/Column_%28database%29http://en.wikipedia.org/wiki/Row_%28database%29
  • 8/9/2019 Week-1a Intro Database

    5/22

    ID CLASS NAME AGE GENDER

    1 6A YERLAN 15 MALE

    2 6A ASEL 15 FEMALE

    3 6A AYGERIM 16 FEMALE

    4 6A KANAT 14 MALE5 6A JANDOS 15 MALE

    6 7A JANAR 16 MALE

    7 7A MARAT 16 MALE

    8 7A BAURJAN 17 MALE

    9 7A AYGUL 16 FEMALE

    10 7A ALIYA 16 FEMALE

    11 7A NURGUL 16 FEMALE

    12 8A ASEL 18 FEMALE

    13 8A SANJAR 19 MALE

    14 8A ALIBEK 18 MALE

    15 8A JANAR 19 FEMALE

    How manyfields

    are there in the table student

    How manyrecords

    are there in the table student

  • 8/9/2019 Week-1a Intro Database

    6/22

    Each column holds data of a particular type

    -Integer-String-Decimal-Date

    If a column in a row contains no data, it is

    NULL.It can indicate no possible value orunavailable data.

  • 8/9/2019 Week-1a Intro Database

    7/22

    ID CLASS NAME AGE GENDER

    1 6A YERLAN 15 MALE

    2 6A ASEL 15 FEMALE

    3 6A AYGERIM 16 FEMALE

    4 6A KANAT 14 MALE5 6A JANDOS 15 MALE

    6 7A JANAR 16 MALE

    7 7A MARAT 16 MALE

    8 7A BAURJAN 17 MALE

    9 7A AYGUL 16 FEMALE

    10 7A ALIYA 16 FEMALE

    11 7A NURGUL 16 FEMALE

    12 8A ASEL 18 FEMALE

    13 8A SANJAR 19 MALE

    14 8A ALIBEK 18 MALE

    15 8A JANAR 19 FEMALE

    NUMBER

    VARCHAR2

  • 8/9/2019 Week-1a Intro Database

    8/22

    Introduction

    SQL is the Structured Query Language

    It is used to interact with the DBMS

    SQL Commands are used to organize database.

  • 8/9/2019 Week-1a Intro Database

    9/22

    USING SQL*PLUS

    SQL*PLUS is a small program that you allow toconnect to oracle database.

    Start / Run

  • 8/9/2019 Week-1a Intro Database

    10/22

    Install on your notebook

    1-Open my intranet site

    2-Download 10201_database_win32.zip3-Unzip and run Setup

  • 8/9/2019 Week-1a Intro Database

    11/22

  • 8/9/2019 Week-1a Intro Database

    12/22

  • 8/9/2019 Week-1a Intro Database

    13/22

    SQL Basics

    Basic SQL statements includeCREATE a data structureSELECT read one or more rows from

    a tableINSERT one of more rows into a tableDELETE one or more rows from atable

    UPDATE change the column values ina row

    DROP a data structure

    In this lecture the focus is on SELECT.

  • 8/9/2019 Week-1a Intro Database

    14/22

    SELECT

    SELECT column FROM tablename

    SELECT column1,column2,column3

    FROM tablename

    SELECT * FROM tablename

    EXAMPLE :

    SELECT * FROM STUDENT;SELECT name,age FROM STUDENT;

  • 8/9/2019 Week-1a Intro Database

    15/22

    How can you see all tables in a current

    database?

    SELECT * FROM TAB

  • 8/9/2019 Week-1a Intro Database

    16/22

    How can you see all records in

    a table STUDENT?

    SELECT * FROM student

    * Means all fields (columns)

  • 8/9/2019 Week-1a Intro Database

    17/22

    How can you see the names and ages of all

    students in a table STUDENT ?

    SELECT name,ageFROM student

  • 8/9/2019 Week-1a Intro Database

    18/22

    How do you know the data types of all fields in

    table STUDENT ?

    DESC student

  • 8/9/2019 Week-1a Intro Database

    19/22

    How do you see the records as sorted by age

    in ascending order?

    SELECT * FROM STUDENT

    ORDER BY AGE

  • 8/9/2019 Week-1a Intro Database

    20/22

    How do you see the records as sorted by age

    in descending order?

    SELECT * FROM STUDENT

    ORDER BY AGE DESC

  • 8/9/2019 Week-1a Intro Database

    21/22

    NOW, IT IS YOUR TURN

  • 8/9/2019 Week-1a Intro Database

    22/22

    TASKS

    1-Connect to the database as SCOTT, in command prompt.2-Connect to the database as SCOTT, in graphic windows.

    3-Connect to the database as SCOTT, in web interface from intranet.

    4-Connect to the database as SCOTT, in web interface from internet.

    5-List all tables from the current database.

    6-List all records from EMP table.7-List all student name from EMP table.

    8-List all rows from EMP table in Ascending order.

    9-List all rows from EMP table in Descending order.

    10-Copy Oracle 10g and install on your notebook( OS :windows XP )