SQL   SQL    

SQL

( .., ..)

SQL

  1. SQL
  2. NULL
  3. ,
  4. (CHECK)
  5. CHECK
  6. ,

, , - . , , . , , , .

, . , , . , SQL , . SQL DDL ( ), SQL.

SQL . , , , .

, , - , , , , .

18.

CREATE TABLE. . DML INSERT (. 15). CREATE TABLE , . . , , .

CREATE TABLE:

CREATE TABLE <table-name >
(<column name > <data type>[(<size>)],
<column name > <data type> [(<size>)] ...);

2, . , , , ANSI. B.

SQL, ( , ). (_) .

. , . , , (. 14).

, . , , , , , .

, , , CHAR. , , . , ( NULL) . , = 1, , . , , , .

. (, Interbase) varchar , NULL, , , : (NULL) '' .

, , , , . , . city . , , ; , Employees, Smith, Smith.Employees - . , Smith (ID), ( ID SQL). 2, 22.

:

CREATE TABLE Saleepeople
(snum integer,
sname char (10),
city char (10),
comm declmal);

, . ( ), .

( ) . , , - , .

, , . 18 , . SQL. , .

SQL, , ANSI. ANSI , .

, . , , cnum=2999. , , , cnum 2999. cnum, 2999 , .

, DML INSERT, UPDATE DELETE, , , . , , , , .

. , , , . , , . .

(, ANSI ):

CREATE INDEX <index name> ON <table name>
(<column name> [,<column name>]...);

, , . - ( ). , . SQL , , , .

, , , snum .

CREATE INDEX Clientgroup ON Customers (snum);

, , , .

, , , , . . , , UNIQUE INDEX. num, , :

CREATE UNIQUE INDEX Custid ON Customers (cnum);

: , cnum. , , , . , , , , .

cnum . . 18 19.

, . . SQL , , , . , , . :

DROP INDEX <Index name>;

.

,

ALTER TABLE ANSI; , , . , . , . , ( 18). , :

ALTER TABLE <table name> ADD <column name> <data type> <size>;

NULL . . , , , . . , , () .

, , , . .

, , , . - ALTER TABLE, , .

ALTER TABLE , , . , ! , , ( 20), , , SQL ( 25), . , , .

, , ALTER TABLE .

ALTER TABLE, , , , INSERT SELECT * .

, (. 22), .

(.. ) , . , SQL , , . , . 15 , . , , :

DROP TABLE <table name>;

, , , . , ( 19), ( 20).

ANSI, SQL, . , , , , , ALTER TABLE. ANSI .

. SQL- . .

. , , . SQL, , ALTER TABLE. DROP TABLE , . , , , .

, . SQL , , , , . SQL. , , . 18 19.

SQL

    1. CREATE TABLE, .
    2. , , .
    3. , onum ( ) ?
    4. , , .
    5. , , , .

(. A .)

17 , . , .

, , .

, , , , ( CREATE TABLE ALTER TABLE). , . , .

, , INSERT . NULL , , .

(, ), , . , SQL , , . . , , .

. , . CREATE TABLE, :

CREATE TABLE <table name>
(<column name> <data type> <column constraint>,
<column name> <data type> <column constraint> ...
<table constraint> (<column name> [, <column name> ])...);

, . , . , , , , . .

(NULL)

CREATE TABLE, (NULL) NOT NULL. .

, NULL , . NULL , . , , . , , , . , , , . NOT NULL ( ) , NULL . SQL , NULL .

, , NULL snum sname:

CREATE TABLE Salespeople (
Snum integer NOT NULL,
Sname char (10) NOT NULL,
city char (10),
comm decimal);

, NOT NULL INSERT, . NULL, SQL , , , , , .

ALTER TABLE, , , , , NOT NULL, . NOT NULL, .

,

17, , . , SQL UNIQUE. , , , ().

, . , UNIQUE ; , . , , .

, , , , . , .

UNIQUE , , , . , (NOT NULL), NULL, NULL .

:

CREATE TABLE Salespeople (
Snum integer NOT NULL UNIQUE,
Sname char (10) NOT NULL UNIQUE,
city char (10),
comm decimal);

sname , , Mary Smith , , Mary Smith M. Smith. snum , , Smith .

( ) , - .

UNIQUE. , , , .

, "a", "b" "b", "a" .

, . , (cnum) (snum) . , :

CREATE TABLE Customers (
cnum integer NOT NULL,
cname char (10) NOT NULL,
city char (10),
rating integer,
snum integer NOT NULL,
UNIQUE (cnum, snum));

, UNIQUE NOT NULL. UNIQUE cnum, .

cnum , cnum snum. , snum , , . , UNIQUE, , .

, , , . , . , , , , snum odate . , , Salestotal:

CREATE TABLE Salestotal (
cnum integer NOT NULL,
odate date NULL,
totamt decimal,
UNIQUE (snum, odate));

, , , :

INSERT INTO Salestotal
SELECT snum, odate, SUM (amt)
FROM Orders
GROUP BY snum, odate;

. , , , "" SQL. UNIQUE , . SQL . SQL (PRIMARY KEY). .

PRIMARY KEY . , UNIQUE, , ( ) . , 19. UNIQUE.

NULL. , UNIQUE, , PRIMARY KEY, NOT NULL.

:

CREATE TABLE Salestotal (
snum integer NOT NULL PRIMARY KEY,
sname char(10) NOT NULL UNIQUE,
city char(10),
comm decimal);

, (UNIQUE) . PRIMARY KEY ( ) , UNIQUE ( sname), .

PRIMARY KEY , . , , ( ). , , , .

PRIMARY KEY :

CREATE TABLE Namefield (
firstname char (10) NOT NULL,
lastname char (10) NOT NULL
city char (10),
PRIMARY KEY (firstname, lastname));

, , , Mary Smith M. Smith. , . , , , UNIQUE .

(CHECK)

, , , , , , , SQL . , SQL CHECK, , , , . CHECK CHECK , . , .

. , ( ) ($).

- , , . 14 .14 , 14.0, , . , CHECK, , 1.

CREATE TABLE Salespeople (
snum integer NOT NULL PRIMARY KEY,
sname char(10) NOT NULL UNIQUE,
city char(10),
comm decimal CHECK (comm < 1));

CHECK,

CHECK, , . , , , , , , -, -. , , . , .

CREATE TABLE Salespeople (
snum integer NOT NULL UNIQUE,
sname char(10) NOT NULL UNIQUE,
city char(10)
CHECK (city IN ('London', 'New York', 'San Jose', 'Barselona')),
comm decimal CHECK (comm<1));

, , , . ALTER TABLE (. 17) , . , , , .

, , (CREATE) , . , , .

:

CREATE TABLE Orders (
onum integer NOT NULL UNIQUE,
amt decimal,
odate date NOT NULL,
cnum integer NOT NULL,
snum integer NOT NULL);

2, DAT () , ANSI. , , , ANSI, DATE? odate , (/) (-) . ASCII, odate CHAR. , , odate . , DATE . , odate CHAR. , , CHECK:

CREATE TABLE Orders (
onum integer NOT NULL UNIQUE,
amt decimal,
odate char (10) NOT NULL CHECK (odate LIKE '--/--/----'),
cnum NOT NULL,
snum NOT NULL);

, , , , .

,

CHECK . , . , .15 . CHECK:

CREATE TABLE Salespeople (
snum integer NOT NULL UNIQUE,
sname char (10) NOT NULL UNIQUE,
city char(10),
comm decimal,
CHECK (comm < .15 OR city = 'Barcelona'));

, , , . , . , SQL . , , CHECK, , . , SQL , , . SQL .

, CHECK , , . , :

CHECK ((comm = .15 AND clty = 'London')
OR (comm = .14 AND city = 'Barcelona')
OR (comm = .11 AND city = 'San Jose')..)

. , , (VIEW) WITH CHECK OPTION, ( 20 21 WITH CHECK OPTION). . , . WITH CHECK OPTION CHECK, 21.

, SQL , . NULL. , NOT NULL .

DEFAULT ( ) CREATE TABLE , , , , DEFAULT , , , , .

, -, -. - city, , :

CREATE TABLE Salespeople (
snum integer NOT NULL UNIQUE,
sname char(10) NOT NULL UNIQUE,
city char(10) DEFAULT = 'New York',
comm decimal CHECK (comm < 1));

, - , , , ( ) . , , , , , , .

, ( ) , .

NULL. NULL () , , IS NULL, . , - . , , , (NULL). NULL , SQL , .

, . , , , , . , = NULL:

SELECT *
FROM Customers
WHERE rating <= 100;

rating = 0, . .

, , ?

, NOT NULL.

, = NULL, .

UNIQUE PRIMARY KEY . , , , . , , , . , UNIQUE PRIMARY KEY ( ) .

, . NOT NULL, NULL, UNIQUE, , PRIMARY KEY, , UNIQUE, , , , CHECK , , , , . , DEFAULT, , INSERT, NULL, DEFAULT NOT NULL.

FOREIGN KEY REFERENCES, 19, , , , , .

SQL

    1. , onum, cnum snum , NULL .
    2. , 10%, NULL, snum , A M (, ).
    3. , , onum , cnum, cnum snum. NULL .

(. A .)

19

, . snum , , snum . cnum cnum . ; , , .

, , . , , DML. , , , . , , . , , , , , , , , , 8.

, . . , snum, , . , , , , . snum cnum .

, , , , . snum , snum, .

, cnum snum , . , , , .

, . , , . , , , , . , , .

, . . , , , , .

, , . , , " ( ) ( )". ( ) () . , , , .

. snum 1001 Hoffman Clemens.

, snum = 1001.

, Hoffman Clemens? , , Hoffman Clemens , !

, , , .

, , : .. . . Hoffman, Clemens Peel, , . , .

, , , 19.1. , .

FOREIGN KEY

SQL FOREIGN KEY. FOREIGN KEY SQL, . , , . , , .

, , . ( ).

FOREIGN KEY CREATE TABLE ( ALTER TABLE), , . , FOREIGN KEY. , , .



19.1. .

, , .

FOREIGN KEY:

FOREIGN KEY <column list> REFERENCES <pktable> [ <column list> ]

, . Pktable , . , . , . , ..:

snum, :

CREATE TABLE Customers (
cnum integer NOT NULL PRIMARY KEY
cname char(10),
city char(10),
snum integer,
FOREIGN KEY (snum) REFERENCES Salespeople (snum));

, ALTER TABLE CREATE TABLE, FOREIGN KEY, , . . ALTER TABLE - , , , , .

FOREIGN KEY (REFERENCES), FOREIGN KEY, REFERENCES, , :

CREATE TABLE Customers (
cnum integer NOT NULL PRIMARY KEY,
cname char(10),
city char(10),
snum integer REFERENCES Salespeople (snum));

Customers.snum , Salespeople.snum. :

FOREIGN KEY (snum) REGERENCES Salespeople (snum)

FOREIGN KEY , , PRIMARY KEY. , , , , , . , PRIMARY KEY snum , ( ) :

CREATE TABLE Customers (
cnum integer NOT NULL PRIMARY KEY,
cname char(10),
city char(10),
snum integer REFERENCES Salespeople);

, .

, , . , , . , () (NULL). , . SQL , (NULL) . , , , , PRIMARY KEY UNIQUE, NOT NULL.

, , . , , ; , . , . , , snum , , snum, , , , , , . ; , , .

snum , , , , - , .

, , . , , . , , , , , .

, , , (NULL). .

NOT NULL, , . , , , , . , NOT NULL, .

,

, , , :

CREATE TABLE Salespeople (
snum integer NOT NULL PRIMARY KEY,
sname char(10) NOT NULL,
city char(10),
comm decimal);

CREATE TABLE Customers (
cnum integer NOT NULL PRIMARY KEY,
cname char(10) NOT NULL,
city char(10),
rating integer,
snum integer,
FOREIGN KEY (snum) REFERENCES Salespeople,
UNIQUE (cnum, snum));

CREATE TABLE Orders (
cnum integer NOT NULL PRIMARY KEY,
amt decimal,
odate date NOT NULL,
cnum integer NOT NULL
snum integer NOT NULL
FOREIGN KEY (cnum, snum) REFERENCES
CUSTOMERS (cnum, snum));

, . , cnum snum , , , , , , . , UNIQUE , . cnum PRIMARY KEY, , , , cnum - .

, , , , .

, ( ) , . , snum cnum , .

, snum , , , . cnum, , , snum ( ). , , , .

, , ( ), . , (denormalization), , . , , .

DML? , , : , INSERT UPDATE . (NULL) , , NULL , NOT NULL. (DELETE) , .

, , ANSI, , : , , . , , , . , , , . , , , . , , , . , , (.. ), () ( 22).

, ANSI, . , :

, . INSERT, , . , . , , . , , UPDATE DELETE. (update effects) (delete effects), , , UPDATE DELETE . , , :

(RESTRICTED) ,

(CASCADES) ,

(NULL) .

ANSI , , . , . , , , . , , .

, , snum , ( , ; , : ). , . , , , . , , - . UPDATE , DELETE .

CREATE TABLE Customers (
cnum integer NOT NULL PRIMARY KEY,
cname char(10) NOT NULL,
city char(10),
rating integer,
snum integer REFERENCES Salespeople,
UPDATE OF Salespeople CASCADES,
DELETE OF Salespeople RESTRICTED);

Peel , , snum Hoffman Clemens . , snum Peel 1009, Hoffman Clemens .

(NULL) . , , . , , . , . , .

CREATE TABLE Orders (
onum integer NOT NULL PRIMARY KEY,
amt decimal,
odate date NOT NULL
cnum integer NOT NULL REFERENCES Customers
snum integer REFERENCES Salespeople,
UPDATE OF Customers CASCADES,
DELETE OF Customers CASCADES,
UPDATE OF Salespeople CASCADES,
DELETE OF Salespeople NULLS);

, DELETE , NOT NULL snum.

,

, FOREIGN KEY , . , . , Employees manager (). , .

, , , . , ( empno), , , , :

CREATE TABLE Employees (
empno integer NOT NULL PRIMARY KEY,
name char(10) NOT NULL UNIOUE,
manager integer REFERENCES Employees);

, . :

EMPNO

NAME

MANAGER

1003

Terrence

2007

2007

Atali

NULL

1688

McKenna

1003

2002

Collier

2007

, ( Atali), . Atali, , NULL. . , , NULL. , ?

, , . , , , . , , , , CREATE TABLE:

CREATE TABLE Salespeople (
snum integer NOT NULL PRIMARY KEY,
sname char(10) NOT NULL,
city char(10),
comm declmal,
cnum integer REFERENCES Customers);

CREATE TABLE Customers (
cnum integer NOT NULL PRIMARY KEY,
cname char(10) NOT NULL,
city char(10),
rating integer,
snum integer REFERENCES Salespeople);

.

SQL , . , , , . , SQL , , . , , . , . , , , , , . , , , , ( , , 22 23).

. , . , , , . , , , , ; . (PRIMARY KEY) (UNIQUE) , , . , , . , , , NULL , UPDATE DELETE.

CREATE TABLE. CREATE. 20 , , . , , , .

SQL

    1. Cityorders. onum, amt, snum , cnum city, , . num Cityorders. Cityorders . , .
    2. . : prev, , onum . . cnum , .

(. A .)

20

(VIEW) , . , . , , .

, , . , , , , .

?

, , . , . . , . DML , .

, ( , , ), . , , . .

CREATE VIEW

CREATE VIEW. CREATE VIEW ( ), , , AS (), , :

CREATE VIEW Londonstaff
AS SELECT *
FROM Salespeople
WHERE city = 'London';

, Londonstaff. , . , , , , , . ( 20.1):

Select *
FROM Londonstaff;

=============== SQL Execution Log ============
| SELECT * |
| FROM Londonstaff; |
| ==============================================|
| snum sname city comm |
| ------ ---------- ----------- ------- |
| 1001 Peel London 0.1200 |
| 1004 Motika London 0.1100 |
=========
======================================

20.1
. Londonstaff

SQL (SELECT) (*) , , Londonstaff, .

, , . , 15, , Londonstaff, (, , ; , ). , , , , .

, , . , , .

. , . , , , ( 20.2)

CREATE VIEW Salesown
AS SELECT snum, sname, city
FROM Salespeople:

=============== SQL Execution Log ============
| SELECT * |
| FROM Salesown; |
| ==============================================|
| snum sname city |
| ------ ---------- ----------- |
| 1001 Peel London |
| 1002 Serres San Jose |
| 1004 Motika London |
| 1007 Rifkin Barcelona |
| 1003 Axelrod
New York |
===============================================

20.2
. Salesown

, , , , comm , , , .

DML, . :

UPDATE Salesown
SET city = 'Palo Alto'
WHERE snum = 1004;

. , UPDATE

UPDATE Salesown
SET comm = .20
WHERE snum = 1004;

, comm Salesown. , , .

21.

, , . . , :

, , . , . , "" . , - , .

, , . SQL , . Londonstaff:

CREATE VIEW Londonstaff
AS SELECT *
FROM Salespeople
WHERE city = 'London';

SELECT *
FROM Londonstaff
WHERE comm > .12;

, :

SELECT *
FROM Salespeople
WHERE city = 'London' AND comm > .12;

, , . , . , , (CREATE) :

CREATE VIEW Ratingcount (rating, number)
AS SELECT rating, COUNT (*)
FROM Customers
GROUP BY rating;

, rating. , , - , :

SELECT *
FROM Ratingcount
WHERE number = 3;

, , :

SELECT rating, COUNT (*)
FROM Customers
WHERE COUNT (*) = 3
GROUP BY rating;

. , COUNT (), . , , :

SELECT rating, COUNT (*)
FROM Customers
GROUP BY rating;
HAVING COUNT (*) = 3;

SQL . Ratingcount ? , ! SQL, .

, , , . , , SQL .

, Ratingcount , GROUP BY, .

. , , , , , , .

, , :

CREATE VIEW Totalforday
AS SELECT odate, COUNT(DISTINCT cnum), COUNT(DISTINCT snum),
COUNT(onum), AVG(amt), SUM(amt)
FROM Orders
GROUP BY odate;

:

SELECT *
FROM Totalforday;

, SQL , , , .

, .

, . SQL , , .

, , , :

CREATE VIEW Nameorders
AS SELECT onum, amt, a.snum, sname, cname
FROM Orders a, Customers b, Salespeople c
WHERE a.cnum = b.cnum AND a.snum = c.snum;

, .

, Rifkin, ( 20.3 ):

SELECT *
FROM Nameorders
WHERE sname = 'Rifkin';

=============== SQL Execution Log ==============
| SELECT * |
| FROM Nameorders |
| WHERE sname = 'Rifkin'; |
| =============================================== |
| onum amt snum sname cname |
| ------ -------- ----- ------- ------- |
| 3001 18.69 1007 Rifkin Ci
sneros |
| 3006 1098.16 1007 Rifkin Cisneros |
================================================

20.3
. Rifkin Nameorders

, , Axelrod :

SELECT a.sname, cname, amt comm
FROM Nameorders a, Salespeople b
WHERE a.sname = 'Axelrod' AND b.snum = a.snum;

20.4.

, "WHERE a.sname = Axelrod' AND b.sname = Axelrod", , , . , snum , , .

=============== SQL Execution Log ==============
| SELECT a.sname, cname, amt * comm |
| FROM Nameorders a, Salespeople b |
| WHERE a.sname = 'Axelrod' AND b.snum = a.snum; |
| =============================================== |
| onum amt snum sname cname |
| ------ -------- ----- ------- ------- |
| 3001 18.69 1007 Rifkin Cisneros |
| 3006 1098.16 1007 Rifkin Cisneros |
===============================
=================

20.4.

, , Axelrod, . snum, .

, . , , . :

CREATE VIEW Elitesalesforce
AS SELECT b.odate, a.snum, a.sname,
FROM Salespeople a, Orders b
WHERE a.snum = b.snum AND b.amt = (SELECT MAX (amt)
FROM Orders c
WHERE c.odate = b.odate);

, , , , , :

CREATE VIEW Bonus
AS SELECT DISTINCT snum, sname
FROM Elitesalesforce a
WHERE 10 <= (SELECT COUNT (*)
FROM Elitesalestorce b
WHERE a.snum = b.snum);

, , :

SELECT *
FROM Bonus;

SQL. RPG COBOL . SQL , .

, , , , .

( ), . , , . 21.

, . ; (UNION) (UNION ALL) . ORDER BY . , .

:

DROP VIEW <view name>

, , , , . , , , .

, , .

, , , . , , . , , .

, , . , 21. , , , , , .

SQL

    1. , .
    2. , .
    3. , . , .
    4. , .

(. A .)

21

DML (INSERT), (UPDATE), (DELETE), . , . .

, , , . , WITH CHECK OPTION, , .

18, , , .

DML. , .

. , , . ; , , . . , 21.1:

CREATE VIEW Citymatch (custcity, salescity)
AS SELECT DISTINCT a.city, b.city
FROM Customers a, Salespeople b
WHERE a.snum = b.snum;

, , , , .

, London London , , , , . Hoffman Peel, .

=============== SQL Execution Log ==============
| SELECT * |
| FROM Citymatch; |
| =============================================== |
| custcity salescity |
| --------- --------- |
| Berlin San Jose |
| London London |
| Rome London |
| Rome New York |
| San Jose Barselona |
| San Jose San Jose |
========================
=========================

21.1
.

, Clemens , , Peel. , .

, , , , - "Lndon London". , , ( , , ORDER BY, ). , , ORDER BY. , . , , . London London ? Hoffman , Clemens , ? Peel ? , . Citymatch " ", , .

, , ; . , " " (updating a view), DML (INSERT, UPDATE DELETE), .

, ? , . : , , , . , , . , , , SQL. , , , SQL, :


" "

, , , . -, , . ( ), ( ), .

( , DISTINCT).

" " .

, , . , , , . , , , , . , . ( 22, , , ).

" ", , . , , . , , (, ) .

" " . , , , , .

" ":

CREATE VIEW Dateorders (odate, ocount)
AS SELECT odate, COUNT (*)
FROM Orders
GROUP BY odate;

" " - GROUP BY.

CREATE VIEW Londoncust
AS SELECT *
FROM Customers
WHERE city = 'London';

.

CREATE VIEW SJsales (name, number, percentage)
AS SELECT sname, snum, comm 100
FROM Salespeople
WHERE city = 'SanJose';

" " - "comm * 100". , , . snum sname.

CREATE VIEW Salesonthird
AS SELECT *
FROM Salespeople
WHERE snum IN (SELECT snum
FROM Orders
WHERE odate = 10/03/1990);

" " ANSI - . , .

CREATE VIEW Someorders
AS SELECT snum, onum, cnum
FROM Orders
WHERE odate IN (10/03/1990,10/05/1990);

.

,

, "" (swallowed) . :

CREATE VIEW Highratings
AS SELECT cnum, rating
FROM Customers
WHERE rating = 300;

. . , (INSERT) :

INSERT INTO Highratings
VALUES (2018, 200);

INSERT . , Highratings, . , , 300. .

200 , , . , , , .

WITH CHECK OPTION ( ) . WITH CHECK OPTION Highratmgs.

CREATE VIEW Highratings
AS SELECT cnum, rating
FROM Customers
WHERE rating = 300
WITH CHECK OPTION;

.

WITH CHECK OPTION __ (all-or-nothing). , DML, , . , , .

, , , .

, , , . , Londonstaff :

CREATE VIEW Londonstaff
AS SELECT snum, sname, comm
FROM Salespeople
WHERE city = 'London';

, city, city .

, , ? city , , , NULL, city (NULL , ; . 18 ). city London, . , Londonstaff. Londonstaff , ( London, ). , , . WITH CHECK OPTION

CREATE VIEW Londonstate
AS SELECT snum, sname, comm
FROM Salespeople
WHERE city = 'London'
WITH CHECK OPTION;

. , , . , ; , , , , . , , , .

, , . , , . , Londonstaff :

CREATE VIEW Londonstaff
AS SELECT *
FROM Salespeople
WHERE city = 'London'
WITH CHECK OPTION;

city, , , :

SELECT snum, sname, comm
FROM Londonstaff;

,

WITH CHECK OPTION ANSI: : , , . ,

CREATE VIEW Highratings
AS SELECT cnum, rating
FROM Customers
WHERE rating = 300
WITH CHECK OPTION;

300 . , ( ) :

CREATE VIEW Myratings
AS SELECT *
FROM Highratings;

, 300:

UPDATE Myratings
SET rating = 200
WHERE cnum = 2004;

, , , . WITH CHECK OPTION , , . , , , WITH CHECK OPTION . , , . , , Myratings

CREATE VIEW Myratings
AS SELECT *
FROM Highratings
WITH CHECK OPTION;

. WITH CHECK OPTION Myratings. Myratings, , , WITH CHECK OPTION . , , Myratings , Highratings .

ANSI, . . , .

. , , , , , , , SQL , .

, , , . , . , " ".

, , , .

" ", , SQL; , , , . , , , .

, WITH CHECK OPTION . WITH CHECK OPTION . , , , . , , , . .

20 21 , . , , . 22 SQL.

SQL

  1. ?
  2. #1 CREATE VIEW Dailyorders
    AS SELECT DISTINCT cnum, snum, onum, odate
    FROM Orders;

    #2 CREATE VIEW Custotals
    AS SELECT cname, SUM (amt)
    FROM Orders, Customers
    WHERE Orders.cnum = customer.cnum
    GROUP BY cname;

    #3 CREATE VIEW Thirdorders
    AS SELECT *
    FROM Dailyorders
    WHERE odate = 10/03/1990;

    #4 CREATE VIEW Nullcities
    AS SELECT snum, sname, city
    FROM Salespeople
    WHERE city IS NULL OR sname BETWEEN 'A' AND 'MZ';

  3. Commissions (). comm snum. , , .10 .20.
  4. SQL , , "CURDATE". CURDATE , , SQL, , SELECT INSERT. Entryorders . , CURDATE odate, . Entryorders, .

(. A .)

  SQL   SQL    

,
- ;
- , - ;
- , ;
- , , .




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution