دروس قواعد البيانات فوكس برو 6 - Fox Pro 6

  • View
    219

  • Download
    0

Embed Size (px)

Transcript

  • 8/14/2019 Fox Pro 6 - 6

    1/66

    6

    Microsoft Visual FoxPro 6.0

    com.arab4hdhd@c

    com.mhmd_hdhd@hotmail

    .1 .2 .3"".4

    .56.SQL7.REPORTCreating Views .8

    9. 1.10 .11

    com.a4cb.www

  • 8/14/2019 Fox Pro 6 - 6

    2/66

    FoxPro6

    " "

    :

    FOXPRO MicrosoftVisual Studio6.0 Microsoft

    Access Microsoft Visual FoxPro 6.0

    new

    new file table

    1

  • 8/14/2019 Fox Pro 6 - 6

    3/66

    save

    fields

    name id

    id

    tab type

    1.character 2.numeric 3.date 8 mm/dd/yy

  • 8/14/2019 Fox Pro 6 - 6

    4/66

    4.logical 5.memo

    numeric tab width 3

    1.decimal 2.index 3.null

    am_call o_phone h_phone OK

    yes

  • 8/14/2019 Fox Pro 6 - 6

    5/66

    * *

    View-

  • 8/14/2019 Fox Pro 6 - 6

    6/66

    Windows-

  • 8/14/2019 Fox Pro 6 - 6

    7/66

    create lesson1 modify

    structure use

    phone

    file -> new

    new database new file

    -& -

  • 8/14/2019 Fox Pro 6 - 6

    8/66

    firstname caption

    input format display

    mask Field validation

    "field "

    comment memo

    ID index

  • 8/14/2019 Fox Pro 6 - 6

    9/66

    indexes type PRIMARY

    *

    Set date dmy

    *

    _screen.caption='NAME"

    _vfp.caption='NAME'

    NAME

    *

    Container EDIT

    relationship

    !

  • 8/14/2019 Fox Pro 6 - 6

    10/66

    !

    one to one

    one to many

    parent table

    primary table

    child table

    related table

    :

    1.Inner JOIN 2.Left JOIN 3.Right JOIN

  • 8/14/2019 Fox Pro 6 - 6

    11/66

    4.Full JOIN

    112033

    =

    INNER JOIN

    1133

    LEFT JOIN

    11233

    RIGHT JOIN

    11 2

    123

  • 8/14/2019 Fox Pro 6 - 6

    12/66

    33

    FULL JOIN

    1102332

    4

    :

    1-

    2-

    3-

    4-

  • 8/14/2019 Fox Pro 6 - 6

    13/66

    .1 .23.

    4. SQL 5. 6.

    .78.

  • 8/14/2019 Fox Pro 6 - 6

    14/66

    9.

    10.

    11.

    .12

  • 8/14/2019 Fox Pro 6 - 6

    15/66

    .13

    Criteria Example

    example

    = 5000=

    Like Cairo=

    == Cairo==

  • 8/14/2019 Fox Pro 6 - 6

    16/66

    > 100>

  • 8/14/2019 Fox Pro 6 - 6

    17/66

    .t. TRUE t

    Expression Builder

  • 8/14/2019 Fox Pro 6 - 6

    18/66

    Query

    Query New File

  • 8/14/2019 Fox Pro 6 - 6

    19/66

    CREATE QUERY COMMAND

    Open

    OK

  • 8/14/2019 Fox Pro 6 - 6

    20/66

    Add Table

    Ctrl +E

  • 8/14/2019 Fox Pro 6 - 6

    21/66

    )( Query

    SQL

    SELECT Table1., Table1., Table1.;

    FROM table1

    table1

    Filter

    Criteria= Example T

    F T ..T

    SQL

    SELECT Table1., Table1., Table1.;

    FROM table1;

    WHERE Table1. = .T.

    table1 =" "

  • 8/14/2019 Fox Pro 6 - 6

    22/66

    200AND

    Order By

  • 8/14/2019 Fox Pro 6 - 6

    23/66

    SQL

    SELECT Table1., Table1., Table1.;

    FROM table1;

    WHERE Table1. = .T.;

    AND Table1. = .T.;

    AND Table1.

  • 8/14/2019 Fox Pro 6 - 6

    24/66

    CREAT

    ALTER

    DROP

    CREAT

    CREATE TABLE PHONE ;(PHONE c(7) PRIMARY KEY, ;Name C(20))

    PHONE

    PHONE C

    20 7

    *

    CREATE TABLE salesman ;(SalesIDc(6) PRIMARY KEY,;

    SaleNameC(20))

    *CREATE TABLE customer ;(SalesIDc(6), ;CustIdi PRIMARY KEY, ;CustNamec(20) UNIQUE,;SalesBranchc(3), ;FOREIGN KEY SalesId TAG SalesId REFERENCES salesman)

    3IUNIQUE

    SalesId SalesId salesman

    *

    CREATE TABLE orders ;(OrderId iPRIMARY KEY, ;

    CustId i REFERENCES customer TAG CustId, ;OrderAmty(4), ;OrderQtyi ;DEFAULT 10 ;CHECK (OrderQty > 9) ;ERROR "Order Quantity must be at least 10", ;

    DiscPercent n(6,2) NULL ;

  • 8/14/2019 Fox Pro 6 - 6

    25/66

    DEFAULT .NULL., ;CHECK (OrderAmt > 0);ERROR "Order Amount Must be > 0" )

    CustId CustId TAG

    CustId i REFERENCES customer TAG CustId

    =10

    DEFAULT 10

    9

    CHECK(OrderQty > 9)

    ERROR"Order Quantity must be at least 10"

    DiscPercent n(6,2) NULL

    n(6,2) 6

    NULL

    n d

    C n C(n)

    D

    T

    N n d N(n,d)

    F n d F(n,d)

    I

    B d B(d)

    Y

    L

    M

  • 8/14/2019 Fox Pro 6 - 6

    26/66

    G

    ALTER

    ALTERTABLE customer ADD COLUMN fax ;

    DROPADD

    ALTERTABLE customer DROP COLUMN fax;

    CHECK

    ; ALTERTABLE orders ALTERCOLUMN quantity DROPCHECK

    DROP

    DROP TABLE | | ? [RECYCLE]

    DROP TABLE

    [RECYCLE]

    DCL

    :GRANT

    GRANT ON TO ALL,SELECT,UPDATE, DELETE _ _ EX1 GRANT ALL ON PHONE TO

    PUBLIC;

    EX2 GRANT DELETE ON PHONE TOAHMED,HDHD;

    EX3 GRANT UPDATE (NAME) ONPHONE TO PUBLIC;

    REVOKE

  • 8/14/2019 Fox Pro 6 - 6

    27/66

    ONALL,SELECT,UPDATE, DELETREVOKETO

    DML

    SELECT

    UPDATE

    DELET

    INSERT

    UPDATE

    =SETUPDATE

    ;*1.1=SETUPDATE

    10%

    UPDATE ) (

    UPDATE [DatabaseName1!]TableName1SET Column_Name1 = eExpression1[, Column_Name2 = eExpression2 ...]WHERE FilterCondition1 [AND | OR FilterCondition2 ...]]

    [DatabaseName1!]TableName1

    SET Column_Name1 = eExpression1

    WHERE FilterCondition1 [AND | OR FilterCondition2 ...]]

    UPDATE customer SET maxordamt = 25

    DELET

    1. DELET FROM BOOKS;2. DELET FROM BOOKS WHERE PRICE >20;

  • 8/14/2019 Fox Pro 6 - 6

    28/66

    1(

    2( 20

    DELETE FROM [DatabaseName!]TableName[WHERE FilterCondition1 [AND | OR FilterCondition2 ...]]

    DELETE FROM customer WHERE country = "USA"

    country "USA"

    INSERT

    INSERT INTO dbf_name [(fname1 [, fname2, ...])]VALUES (eExpression1 [, eExpression2, ...])

    dbf_name ) (

    [(fname1 [, fname2 [, ...]])]

    VALUES (eExpression1 [, eExpression2 [, ...]])

    INSERT INTO employee (emp_no, fname, lname, officeno) ;

    VALUES (3022, "John", "Smith", 2101)

    INSERT INTO TableName (F1,F2) VALUES(V1,V2,);

    TableName F1 V1

    2

    ;INSERT INTO BOOKS VALUES(VB6,25,400)

  • 8/14/2019 Fox Pro 6 - 6

    29/66

    3

    INSERT INTO BOOKS (TITLE,PRICE,PAGE) VALUES(VB6,25,400);

    4

    INSERT INTO BOOKS SELECT TITLES.* FROM TITLES.*;

    BOOKS TITLES

    SELECT

    SELECT

    SELECT

    FROM

    WHERE

    GROUP BY

    HAVING

    ORDER BY

    SQL

    SELECT [DISTINCT|ALL] {*|[column_name [AS new_name]] [,.]}

    FROM table_name [alias] [,]

    [WHERE condition]

  • 8/14/2019 Fox Pro 6 - 6

    30/66

    [GROUP BY column_list] [HAVING condition]

    [ORDER BY column_list

    DISTINCT " "

    Alias

    column_list

    SQL

    SELECT fields FROM table;

    FROM table;*SELECT

    SELECT FIELED , "" FIELD2 FROM TABLE

  • 8/14/2019 Fox Pro 6 - 6

    31/66

    1 2

    WHERE

    SELECT *FROM TABLE WHERE Fn=VALUE

    =

    )< >=>== 1000

    1000

    UK

    (SELECT company FROM customer WHERE country = "UK")

    customer.postalcode BETWEEN 90000 AND 99999

    customer.postalcode NOTIN ("98052","98072","98034")

    NOT LIKE

    customer.country NOT LIKE "UK"

    % _LIKE

    %A A

    %A A

    A A_ _ _

    A _ _ _A

  • 8/14/2019 Fox Pro 6 - 6

    32/66

    SELECT country, postalcode, company ;

    FROM customer ;

    ORDER BY country, postalcode, company

    SELECT a.company, b.order_date, b.shipped_on ;FROM customer a, orders b ;WHERE a.cust_id = b.cust_id ;INTO TABLE custship.dbf

    16/2/1994

    SELECT a.company, b.order_date, b.shipped_on ;FROM customer a, orders b ;WHERE a.cust_id = b.cust_id ;AND b.order_date < {^1994-02-16}

    ; Select Sysdate from Dual Select Next_day (sysdate) from Dual ;

    Select Last_day (sysdate) from Dual ;; Select Sysdate + 10 from Dual

    Select Sysdate - 10 from Dual ; ; 22/5