SQL for Data Analysis(Create, UPADTE, Delete Table)

  • CREATE TABLE creates a new table.
  • INSERT INTO adds a new row to a table.
  • SELECT queries data from a table.
  • ALTER TABLE changes an existing table.
  • UPDATE edits a row in a table.
  • DELETE FROM deletes rows from a table
CREATE TABLE friends
(id INTEGER,
name TEXT,
birthday DATE
);
INSERT INTO friends(id,name,birthday)
VALUES(1,'Jane Doe','1990-05-30');
INSERT INTO friends(id,name,birthday)
VALUES(2,'Ali Pansare','1998-08-15');
INSERT INTO friends(id,name,birthday)
VALUES(3'Junaid Patel','1996-05-22');
UPDATE friends
SET name = 'Jane Smith'
where id = 1;
ALTER TABLE friends
ADD COLUMN email TEXT;
UPDATE friends
SET email = 'jane@codecademy.com'
where id = 1;
UPDATE friends
SET email = 'ap@gmail.com'
where id = 2;
UPDATE friends
SET email = 'jp@yahoo.com'
where id = 3;
DELETE from friends
where name = 'Jane Smith';



Select *
FROM friends;

Comments

Popular posts from this blog

Binomial Test in Python

Python Syntax and Functions Part2 (Summary Statistics)

Slicing and Indexing in Python Pandas