Advertisement
Guest User

Untitled

a guest
May 14th, 2019
1,087
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. 1.
  2. Adding data =
  3.  
  4. INSERT INTO items (id, name, price)
  5. VALUES
  6. (1, 'two', 1.99)
  7.  
  8. Update data =
  9.  
  10. UPDATE items SET price =2.50 WHERE id=1;
  11.  
  12. Delete data =
  13.  
  14. DELETE FROM items WHERE id=1;
  15.  
  16. 2.
  17. As demonstrated about in order to add data you need to have the table name the type of values you want and then the data itself.
  18. To update data you need the table name and then to specify what type you want to update with a value and where you want it to be updated
  19. in my example above the where would be the id column.
  20.  
  21. To delete data you just need the table name and what you want to delete.
  22.  
  23. 3.
  24. Money: How much and item costs on Amazon
  25. Date: The date shown on your computer calendar
  26. Timestamp: The timestamp of a message that was sent on Facebook messenger.
  27. Time: The time shown on your computer
  28.  
  29. 4.
  30.  
  31. A.
  32.  
  33. The table will have the following COLUMNS:
  34.  
  35. First name, Last Name, RSVP Received, Guests, Meals
  36.  
  37. Types of DATA to be used:
  38.  
  39. First and Last Name: Text
  40. RSVP Received: Boolean
  41. Guests: Integer
  42. Meals: Integer
  43.  
  44. B.
  45.  
  46. CREATE TABLE wedding dinner (
  47.  
  48. name text,
  49. rsvp boolean,
  50. guests integer,
  51. meals integer
  52. );
  53.  
  54. C.
  55.  
  56. ALTER TABLE dinner ADD COLUMN thankyou boolean;
  57.  
  58. D.
  59.  
  60. ALTER TABLE dinner DROP COLUMN meals;
  61.  
  62. E.
  63.  
  64. ALTER TABLE dinner ADD COLUMN tablenumber integer;
  65.  
  66. F.
  67.  
  68. ALTER TABLE dinner DROP COLUMN tablenumber;
  69.  
  70. 5.
  71.  
  72. A.
  73.  
  74. CREATE TABLE library (
  75. ISBN integer,
  76. title text,
  77. author text,
  78. genre text,
  79. publishing_date date,
  80. number_of_copies integer,
  81. available_copies integer
  82. )
  83.  
  84. B.
  85.  
  86. INSERT INTO library (ISBN, title, author, genre, publishing_date, number_of_copies, available_copies)
  87. VALUES
  88. (0553103547,'Game of Thrones(Book 1)', 'George R. R. Martin', 'Epic fantasy', 08-1996, 5, 1)
  89. (0553108034, 'A Clash of Kings', 'George R. R. Martin', 'Epic fantasy', 08-1998, 5, 0)
  90. (0553106635, 'A Storm of Swords', 'George R. R. Martin','Epic fantasy', 08-2000, 5, 5)
  91.  
  92. C.
  93. UPDATE library SET available_copies=available_copies - 1 WHERE ISBN=0553106635;
  94.  
  95. D.
  96. DELETE FROM library WHERE ISBN=0553108034;
  97.  
  98. 6.
  99. A.
  100. CREATE TABLE spacecrafts (
  101. id integer,
  102. name text,
  103. year_launched integer,
  104. country_of_origin text,
  105. mission_description text,
  106. orbiting_body text,
  107. currently_operating boolean,
  108. approx_miles_from_earth integer
  109. );
  110.  
  111. B.
  112.  
  113. INSERT INTO spacecrafts (id, name, year_launched, country_of_origin, mission_description, orbiting_body, currently_operating, approx_miles_from_earth)
  114. VALUES
  115. (1, 'Ship 1', 1988, 'USA', 'Play tunes on Neptune.', 'Neptune', TRUE, 2,700,000,000),
  116. (2, 'Ship 2', 1989, 'USA', 'Capture the stars while on Mars.', 'Mars', TRUE, 33,900,000),
  117. (3, 'Ship 3', 1990, 'USA', 'Release ballons on the moon.', 'Moon', TRUE, 225,000);
  118.  
  119. C.
  120. DELETE FROM spacecrafts WHERE id=3;
  121.  
  122. D.
  123. UPDATE spacecrafts SET currently_operating=FALSE WHERE id=2;
  124.  
  125. 7.
  126. A.
  127. CREATE TABLE emails (
  128. id integer,
  129. subject_line text,
  130. sender text,
  131. additional_recipients text[],
  132. body text,
  133. timestamp TIMESTAMP,
  134. read boolean,
  135. chain_id integer
  136. );
  137.  
  138. B.
  139. INSERT INTO emails (id, subject_line, sender, additional_recipients, body, timestamp, read, chain_id)
  140. VALUES
  141. (1, 'Extended Warranty', 'kyla@mail.com', '{curt@mail.com, shlomo@mail.com} , ' How much is extended warranty', '2019-05-01 09:50:00', TRUE, 1)
  142. (1, 'RE:Extended Warranty', 'shlomo@mail.com', '{curt@mail.com, kyla@mail.com} , ' 3000 for 3 years on the gold plan', '2019-05-01 09:55:00', TRUE, 1)
  143. (1, 'RE: RE:Extended Warranty', 'curt@mail.com', '{shlomo@mail.com, kyla@mail.com} , 'That sounds perfect sign us up!', '2019-05-01 09:59:00', TRUE, 1)
  144.  
  145. C.
  146. DELETE from emails WHERE sender='kyla@mail.com';
  147.  
  148. D.
  149. UPDATE emails SET read=FALSE WHERE sender='shlomo@mail.com'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement