• oracle 开发 第01章 简介


    2016-01-04

    一、DCL语句
    1.创建用户store

    create user store identified by store_password;

    2.授予权限connect、resource

    grant connect,resource to store;

    二、DDL语句
    1.创建customers表

    create table customers (
    customer_id integer constraint customers_pk primary key,
    first_name varchar2(10) not null,
    last_name varchar2(10) not null,
    dob date,
    phone varchar2(12));

    2.创建product_types表

    create table product_types (
    product_type_id integer constraint product_types_pk primary key,
    name varchar2(10) not null);

    3.创建products表

    create table products (
    product_id integer constraint products_pk primary key,
    product_type_id integer constraint products_fk_product_types references product_types(product_type_id),
    name varchar2(30) not null,
    description varchar2(50),
    price number(5,2));

    4.创建purchases表

    create table purchases(
    product_id integer constraint purchases_fk_products references products(product_id),
    customer_id integer constraint purchases_fk_customers references customers(customer_id),
    quantity integer not null,
    constraint purchases_pk primary key (product_id,customer_id));

    5.创建employees表

    create table employees(
    employee_id integer constraint employees_pk primary key,
    manager_id integer,
    first_name varchar2(10) not null,
    last_name varchar2(10) not null,
    title varchar2(20),
    salary number(6,0));

    6.创建salary_grades表

    create table salary_grades(
    salary_grade_id integer constraint salary_grade_pk primary key,
    low_salary number(6,0),
    high_salary number(6,0));

    三、DML语句
    1.向customers表插入数据

      在linux服务器上操作

    insert all 
    into customers values (1,'John','Brown',to_date('01-JAN-65','DD-MON-RR'),'800-555-1211')
    into customers values (2,'Cynthia','Green',to_date('05-FEB-68','DD-MON-RR'),'800-555-1212')
    into customers values (3,'Steve','White',to_date('16-MAR-71','DD-MON-RR'),'800-555-1213')
    into customers values (4,'Gail','Black','','800-555-1214')
    into customers values (5,'Doreen','Blue',to_date('20-MAY-70','DD-MON-RR'),' ')
    select 1 from dual;

      在windows客户端上操作

    insert all 
    into customers values (1,'John','Brown',to_date('1965/01/01','yyyy/mm/dd'),'800-555-1211')
    into customers values (2,'Cynthia','Green',to_date('1968/02/05','yyyy/mm/dd'),'800-555-1212')
    into customers values (3,'Steve','White',to_date('1971/03/16','yyyy/mm/dd'),'800-555-1213')
    into customers values (4,'Gail','Black','','800-555-1214')
    into customers values (5,'Doreen','Blue',to_date('1970/04/20','yyyy/mm/dd'),'')
    select 1 from dual;

    2.向product_types表插入数据

    insert all
        into product_types values (1,'Book')
        into product_types values (2,'Video')
        into product_types values (3,'DVD')
        into product_types values (4,'CD')
        into product_types values (5,'Magazine')
    select 1 from dual;

    3.向products表插入数据

    insert all
        into products values (1,1,'Modern Science','A description of modern science',19.95)
        into products values (2,1,'Chemistry','Introduction to Chemistry',30)
        into products values (3,2,'Supernova','A star explodes',25.99)
        into products values (4,2,'Tank War','Action movie about a future war',13.95)
    select 1 from dual;

    4.向purchases表插入数据

    insert all
        into purchases values (1,1,1)
        into purchases values (2,1,3)
        into purchases values (1,4,1)
        into purchases values (2,2,1)
        into purchases values (1,3,1)
    select 1 from dual;

    5.向employees表插入数据

    insert all
        into employees values (1,'','James','Smith','CEO',800000)
        into employees values (2,1,'Ron','Johnson','Sales Manager',600000)
        into employees values (3,2,'Fred','Hobbs','Salesperson',150000)
        into employees values (4,2,'Susan','Jones','Salesperson',500000)
    select 1 from dual;

    6.向salary_grades表插入数据

    insert all
        into salary_grades values (1,1,250000)
        into salary_grades values (2,250001,500000)
        into salary_grades values (3,500001,750000)
        into salary_grades values (4,750001,999999)
    select 1 from dual;

    7.INSERT语句

    insert into customers 
    (customer_id,first_name,last_name,dob,phone)
    values 
    (6,'Fred','Brown',to_date('1970/01/01','yyyy/mm/dd'),'800-555-1215');

    8.UPDATE语句

    update customers set last_name = 'Orange' where customer_id = 2;

    9.DELETE语句

    delete from customers where customer_id = 6;

    【参考资料】

    [1] Jason Price.精通Oracle Database 12c SQL&PLSQL编程(第3版).[M].北京:清华大学出版社,2014

  • 相关阅读:
    java的(PO,VO,TO,BO,DAO,POJO)解释
    java中的几种对象(PO,VO,DAO,BO,POJO)
    mybatis如何根据mapper接口生成其实现类
    MyBatis接口的简单实现原理
    Fast-settling synchronous-PWM-DAC filter has almost no ripple
    CMOS DACs act as digitally controlled voltage dividers
    Programmable current source requires no power supply
    Add margining capability to a dc/dc converter
    Use an LM317 as 0 to 3V adjustable regulator
    Simple microcontroller-temperature measurement uses only a diode and a capacitor
  • 原文地址:https://www.cnblogs.com/cenliang/p/5098176.html
Copyright © 2020-2023  润新知