Basic SQL*Plus edit and execute commands SQL*Plus buffer and built-in editor holds the last SQL statement Statements are created in free-flow style and.

Slides:



Advertisements
Similar presentations
Session 2Introduction to Database Technology Data Types and Table Creation.
Advertisements

Data Definition Language (DDL)
SQL’s Data Definition Language (DDL) n DDL statements define, modify and remove objects from data dictionary tables maintained by the DBMS n Whenever you.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Structured Query Language - SQL Carol Wolf Computer Science.
1 A GUIDE TO ORACLE8 CHAPTER 2: Creating and ModifyingDatabaseTables 2.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
1 Chapter 2: Creating and Modifying Database Tables.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Creating Database Tables © Abdou Illia MIS Spring /21/2015.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Database Management System LICT 3011 Eyad H. Elshami.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Oracle Data Definition Language (DDL)
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
1 An Introduction to SQL. 2 Objectives  Understand the concepts and terminology associated with relational databases  Create and run SQL commands 
Database Design lecture 3_1 1 Database Design Lecture 3_1 Data definition in SQL.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
1 The Relational Model Instructor: Mohamed Eltabakh
Chapter 8 Part 1 SQL-99 Schema Definition, Constraints, Queries, and Views.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
CSC 2720 Building Web Applications Database and SQL.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
1 Creating and Modifying Database Objects. 2 An Oracle database consists of multiple user accounts Each user account owns database objects Tables Views.
CS 3630 Database Design and Implementation. Assignment 3 Style! Agreement between database designer and the client. UserName1_EasyDrive UserName2_EasyDrive.
1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.
SQL: DDL John Ortiz Cs.utsa.edu.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Intro to SQL| MIS 2502  Spacing not relevant › BUT… no spaces in an attribute name or table name  Oracle commands keywords, table names, and attribute.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
CS 3630 Database Design and Implementation. Database Schema Branch (Bno…) Staff (Sno…Bno) Owner (Ono…) PropertyForRent (Pno…Ono) Renter (Rno…) Viewing.
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Copyright  Oracle Corporation, All rights reserved. Introduction.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
1 Chapter 2: Creating and Modifying Database Objects.
Sql DDL queries CS 260 Database Systems.
Personal Oracle8i Create a new user Create a new table Enter data into a new table Export & import data Start and exit SQL Plus SQL Plus Syntax.
Week 8-9 SQL-1. SQL Components: DDL, DCL, & DML SQL is a very large and powerful language, but every type of SQL statement falls within one of three main.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
3 A Guide to MySQL.
CIT 214 Introduction to Database Management
CS 3630 Database Design and Implementation
Managing Tables, Data Integrity, Constraints by Adrienne Watt
SQL and SQL*Plus Interaction
ORACLE SQL Developer & SQLPLUS Statements
Instructor: Mohamed Eltabakh
SQL data definition using Oracle
Oracle Data Definition Language (DDL)
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Chapter 2: Creating And Modifying Database Tables
Introduction to Oracle
SQL (Structured Query Language)
Presentation transcript:

Basic SQL*Plus edit and execute commands SQL*Plus buffer and built-in editor holds the last SQL statement Statements are created in free-flow style and are numbered Example: select Custnumb, Balance from CUSTOMER The semicolon indicates the end of the SQL statement and causes execution A builtin editor is used to change the statements in the buffer after it has been created Append Credlim to the current listing Change the SELECT statement to return Custname rather than Custnumb

Basic SQL*Plus edit and execute commands contd. Insert a new line ORDER BY SLSRNUMB after the current line List the current statement in the buffer Formatting columns

Basic SQL*Plus edit and execute commands contd. The SQL statement in the buffer can be saved to a file A file may contain any number of SQL statements Comments: --for a single line of text /* for multi-line texts */ Editing and running a file

Table: columns, rows Valid Oracle object names must be unique <= 30 characters not a reserved word must start with a letter can contain letters, digits, some special characters (_,$,#) Data types for columns: VARCAHR2 variable length character string up to 2000 characters must specify length-- Example: slname VARCHAR2 (30) CHAR fixed length character string up to 255 characters should not be used if exact length is not known NUMBER: integer, fixed point, floating point numbers INTEGER: whole numbers Example: sid number(5) fixed-point numbers: price NUMBER (5,2) floating point numbers: gpa NUMBER Database tables

Database tables cont’d Data types cont’d DATE: no length specification needed. Various format masks can be used LONG: used for very large character data. Do not use RAW/LONG RAW: used for binary data--digitized image. Integrity constraints Primary key: sid NUMBER (5) CONSTRAINT student_pk PRIMARY KEY Foreign key: locid NUMBER (5) CONSTRAINT faculty_fk REFERENCES location(locid) Value constraints check that gpa is between 0 and 4 gpa NUMBER (5,2) CONSTRAINT gpa_cc CHECK gpa between 0 and 4 Creating/modifying/dropping tables: CREATE TABLE ( [CONSTRAINT ],....) Example: CREATE TABLE location (locid number (5) CONSTRAINT location_pk PRIMARY KEY......); DROP TABLE Example: DROP TABLE location;

Database tables cont’d Viewing table structure field definition: describe Example: Constraint definition user_constraints table Modifying tables changing a columns size, data type, default value adding/deleting PK, FK constraints deleting column/changing column name--not allowed adding a new column

Database tables cont’d Modifying table definitions Adding column/constraints ALTER TABLE ADD ( / ) Modifying existing table ALTER TABLE MODIFY ( / ) Dropping constraints ALTER TABLE DROP CONSTRINT