rbi-learning / Today-I-Learned

1 stars 0 forks source link

8/13 Sara Ho #129

Open saraashleyho opened 4 years ago

saraashleyho commented 4 years ago

Today I Learned

INTRO TO SQL

Creating a new table: CREATE TABLE tablename ( _Column_name 1 datatype (example: serial) PRIMARY KEY, Column_name 2 datatype (example: varchar(50) NOT NULL, Columnname 3 datatype (example: int), );

Selecting ALL data from a table: SELECT * FROM tablename;

Inserting new data into a table: INSERT INTO tablename (column1, column2, column3) VALUES (value1, value 2, value 3);

Updating something in table for specific criteria: UPDATE tablename SET column1 = value1, column2 = value2 WHERE (some criteria) RETURNING *;

Ordering data a specific way SELECT column1, column 2, column 3 FROM tablename ORDER BY column1 DESC

Deleting data from a table DELETE FROM tablename WHERE (some criteria); *Note - be careful when using a delete command! You may delete more than you want if you don't specify "where"

Using SQL in our Task Manager app

image