Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.
- Adding data =
- INSERT INTO items (id, name, price)
- VALUES
- (1, 'two', 1.99)
- Update data =
- UPDATE items SET price =2.50 WHERE id=1;
- Delete data =
- DELETE FROM items WHERE id=1;
- 2.
- 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.
- 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
- in my example above the where would be the id column.
- To delete data you just need the table name and what you want to delete.
- 3.
- Money: How much and item costs on Amazon
- Date: The date shown on your computer calendar
- Timestamp: The timestamp of a message that was sent on Facebook messenger.
- Time: The time shown on your computer
- 4.
- A.
- The table will have the following COLUMNS:
- First name, Last Name, RSVP Received, Guests, Meals
- Types of DATA to be used:
- First and Last Name: Text
- RSVP Received: Boolean
- Guests: Integer
- Meals: Integer
- B.
- CREATE TABLE wedding dinner (
- name text,
- rsvp boolean,
- guests integer,
- meals integer
- );
- C.
- ALTER TABLE dinner ADD COLUMN thankyou boolean;
- D.
- ALTER TABLE dinner DROP COLUMN meals;
- E.
- ALTER TABLE dinner ADD COLUMN tablenumber integer;
- F.
- ALTER TABLE dinner DROP COLUMN tablenumber;
- 5.
- A.
- CREATE TABLE library (
- ISBN integer,
- title text,
- author text,
- genre text,
- publishing_date date,
- number_of_copies integer,
- available_copies integer
- )
- B.
- INSERT INTO library (ISBN, title, author, genre, publishing_date, number_of_copies, available_copies)
- VALUES
- (0553103547,'Game of Thrones(Book 1)', 'George R. R. Martin', 'Epic fantasy', 08-1996, 5, 1)
- (0553108034, 'A Clash of Kings', 'George R. R. Martin', 'Epic fantasy', 08-1998, 5, 0)
- (0553106635, 'A Storm of Swords', 'George R. R. Martin','Epic fantasy', 08-2000, 5, 5)
- C.
- UPDATE library SET available_copies=available_copies - 1 WHERE ISBN=0553106635;
- D.
- DELETE FROM library WHERE ISBN=0553108034;
- 6.
- A.
- CREATE TABLE spacecrafts (
- id integer,
- name text,
- year_launched integer,
- country_of_origin text,
- mission_description text,
- orbiting_body text,
- currently_operating boolean,
- approx_miles_from_earth integer
- );
- B.
- INSERT INTO spacecrafts (id, name, year_launched, country_of_origin, mission_description, orbiting_body, currently_operating, approx_miles_from_earth)
- VALUES
- (1, 'Ship 1', 1988, 'USA', 'Play tunes on Neptune.', 'Neptune', TRUE, 2,700,000,000),
- (2, 'Ship 2', 1989, 'USA', 'Capture the stars while on Mars.', 'Mars', TRUE, 33,900,000),
- (3, 'Ship 3', 1990, 'USA', 'Release ballons on the moon.', 'Moon', TRUE, 225,000);
- C.
- DELETE FROM spacecrafts WHERE id=3;
- D.
- UPDATE spacecrafts SET currently_operating=FALSE WHERE id=2;
- 7.
- A.
- CREATE TABLE emails (
- id integer,
- subject_line text,
- sender text,
- additional_recipients text[],
- body text,
- timestamp TIMESTAMP,
- read boolean,
- chain_id integer
- );
- B.
- INSERT INTO emails (id, subject_line, sender, additional_recipients, body, timestamp, read, chain_id)
- VALUES
- (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)
- (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)
- (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)
- C.
- DELETE from emails WHERE sender='kyla@mail.com';
- D.
- UPDATE emails SET read=FALSE WHERE sender='shlomo@mail.com'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement