Skip to content

Course Notes

Use this workspace to take notes, store sample queries, and build your own interactive cheat sheet!

You will need to connect your SQL cells to an integration to run a query.

  • You can use a sample integration from the dropdown menu. This includes the Course Databases integration, which contains tables you used in our SQL courses.
  • You can connect your own integration by following the instructions provided here.

Note: When using sample integrations such as those that contain course data, you have read-only access. You can run queries, but cannot make any changes such as adding, deleting, or modifying the data (e.g., creating tables, views, etc.).

Take Notes

Add notes here about the concepts you've learned and SQL cells with code you want to keep.

Add your notes here

Spinner
DataFrameas
df
variable
-- A sample query for you to replace!
SELECT 
    *
FROM books
Spinner
DataFrameas
df1
variable
-- Query the right table in information_schema
SELECT table_name 
FROM information_schema.tables
-- Specify the correct table_schema value
WHERE table_schema = 'public';
Spinner
DataFrameas
df2
variable
-- Query the right table in information_schema to get columns
SELECT column_name, data_type 
FROM information_schema.columns 
WHERE table_name = 'university_professors' AND table_schema = 'public';
Spinner
Queryas
query
variable
-- Query the first five rows of our table
SELECT * 
FROM  public.university_professors
LIMIT 5;
Spinner
DataFrameas
df3
variable
-- Rename the organisation column
ALTER TABLE affiliations
RENAME COLUMN organisation TO organization;

-- Delete the university_shortname column
ALTER TABLE affiliations
DROP COLUMN university_shortname;
Spinner
DataFrameas
df4
variable
-- Insert unique professors into the new table
INSERT INTO professors 
SELECT DISTINCT firstname, lastname, university_shortname 
FROM university_professors;

-- Doublecheck the contents of professors
SELECT * 
FROM professors;
Spinner
DataFrameas
df5
variable
-- Specify the correct fixed-length character type
ALTER TABLE public.professors
ALTER COLUMN university_shortname
TYPE varchar(3);