1 / 10

DBMS

DBMS. TUTORIAL 3. Loading Data into a Table. Fluffy Harold cat f 1993-02-04 N Claws Gwen cat m 1994-03-17 N Buffy Harold dog f 1989-05-13 N Fang Benny dog m 1990-08-27 N Bowser Diane dog m 1979-08-31 1995-07-29 Chirpy Gwen bird f 1998-09-11 N

baba
Download Presentation

DBMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DBMS TUTORIAL 3

  2. Loading Data into a Table

  3. Fluffy Harold cat f 1993-02-04 \N Claws Gwen cat m 1994-03-17 \N Buffy Harold dog f 1989-05-13 \N Fang Benny dog m 1990-08-27 \N Bowser Diane dog m 1979-08-31 1995-07-29 Chirpy Gwen bird f 1998-09-11 \N Whistler Gwen bird \N 1997-12-09 \N Slim Benny snake m 1996-04-29 \N

  4. LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet; • Example: • LOAD DATA LOCAL INFILE ‘H:\pet.txt’ INTO TABLE pet;

  5. UPDATE DATA • UPDATE pet SET birth = '1989-08-31' WHERE name = 'Bowser';

  6. Selecting Particular Rows • SELECT * FROM pet WHERE name = 'Bowser'; • SELECT * FROM pet WHERE species = 'dog' AND sex = 'f';

  7. Selecting Particular Columns • SELECT name, birth FROM pet; • SELECT name, species, birth FROM pet WHERE species = 'dog' OR species = 'cat';

  8. Sorting Rows • SELECT name, birth FROM pet ORDER BY birth; • SELECT name, birth FROM pet ORDER BY birth DESC;

  9. SELECT name, species, birth FROM pet ORDER BY species, birth DESC;

  10. Date Calculations • SELECT name, birth, CURDATE(), (YEAR(CURDATE())-YEAR(birth)) AS age FROM pet;

More Related