SQL Intro: Learning to Query Databases with DDL and DML Commands, Slides of Introduction to Database Management Systems

An introduction to structured query language (sql), explaining its two main categories: data definition language (ddl) and data manipulation language (dml). Ddl includes commands to create database objects and define access rights, while dml includes commands to insert, update, delete, and retrieve data. Sql is relatively easy to learn with a small vocabulary and is used to interact with relational databases. Sql data definition commands, data manipulation commands, data types, creating table structures, and sql constraints.

Typology: Slides

2012/2013

Uploaded on 04/27/2013

sonu
sonu 🇮🇳

4.3

(14)

41 documents

1 / 79

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Structured
Query Language (SQL)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f

Partial preview of the text

Download SQL Intro: Learning to Query Databases with DDL and DML Commands and more Slides Introduction to Database Management Systems in PDF only on Docsity!

Introduction to Structured

Query Language (SQL)

In this chapter, you will learn:

  • The basic commands and functions of SQL
  • How to use SQL for data administration (to create tables, indexes, and views)
  • How to use SQL for data manipulation (to add, modify, delete, and retrieve data)
  • How to use SQL to query a database to extract useful information

Introduction to SQL (continued)

  • SQL is relatively easy to learn
  • Basic command set has a vocabulary of less than 100 words
  • Nonprocedural language
  • American National Standards Institute (ANSI) prescribes a standard SQL
  • Several SQL dialects exist

SQL Data Definition

Commands

Data Definition Commands

  • Examine the simple database model and the database tables that will form the basis for the many SQL examples
  • Understand the data environment

The Database Model

The Database Schema

  • Authentication
    • Process through which the DBMS verifies that only registered users are able to access the database
    • Log on to the RDBMS using a user ID and a password created by the database administrator
  • Schema
    • Group of database objects—such as tables and indexes—that are related to each other

Data Types

  • Data type selection is usually dictated by the nature of the data and by the intended use
  • Pay close attention to the expected use of attributes for sorting and data retrieval purposes

Creating Table Structures

  • Use one line per column (attribute) definition
  • Use spaces to line up the attribute characteristics and constraints
  • Table and attribute names are capitalized
  • NOT NULL specification
  • UNIQUE specification
  • Primary key attributes contain both a NOT NULL and a UNIQUE specification
  • RDBMS will automatically enforce referential integrity for foreign keys
  • Command sequence ends with a semicolon

Other SQL Constraints

  • NOT NULL constraint
    • Ensures that a column does not accept nulls
  • UNIQUE constraint
    • Ensures that all values in a column are unique
  • DEFAULT constraint
    • Assigns a value to an attribute when a new row is added to a table
  • CHECK constraint
    • Validates data when an attribute value is entered

A Duplicated TEST Record

Data Manipulation Commands

  • Adding table rows
  • Saving table changes
  • Listing table rows
  • Updating table rows
  • Restoring table contents
  • Deleting table rows
  • Inserting table rows with a select subqueryDocsity.com

A Data View and Entry

Form

Saving Table Changes

  • Changes made to table contents are not physically saved on disk until - Database is closed - Program is closed - COMMIT command is used
  • Syntax
    • COMMIT [WORK]
  • Will permanently save any changes made to any table in the database Docsity.com