随笔分类 - Postgres
摘要:Server wait for database get ready # From https://docs.docker.com/compose/startup-order/ #!/bin/sh # wait-for-postgres.sh set -e host="$1" shift # Log
阅读全文
摘要:For examlpe, we have two tables: cars: make: For cars table, we want to know 'make_name' instead of 'make_id', we can do with 'join' two tables. In or
阅读全文
摘要:Instead of first checking to see if a record already exists within your table, we can do a on conflict do update. In this command, we can ether insert
阅读全文
摘要:SQL is dynamic enough to handle queries within queries. These inner queries are called subqueries and they can be used in many different sections of a
阅读全文
摘要:SQL gives us the power to choose what data we pull out of our table. We will use the where clause within our select statement with many operators. The
阅读全文
摘要:Another powerful SQL skill is understanding how to group rows together by column values. Once the data is grouped together, it can be difficult to und
阅读全文
摘要:If the data in your tables do not have integrity, meaning there are missing rows, incorrect values, or duplicate rows, your table is not worth much. D
阅读全文
摘要:Delete: delete from Users where last_name = 'clark'; If you wanted to delete everything in our table, I mentioned you could just use the delete comman
阅读全文
摘要:PostgreSQL allows you store and compare UUID values but it does not include functions for generating the UUID values in its core. Instead, it relies o
阅读全文
摘要:Install: brew install postgresql Start: brew services start postgresql psql postgres Create a table: $ postgres=# create table Users ( $ postgres(# cr
阅读全文
摘要:When working with databases, it seems inevitable that you will find yourself needing to export data from a table to send along to another team, compan
阅读全文
摘要:Every movie needs a director and every rented movie needs to exist in the store. How do we make sure something in another table exists before insertin
阅读全文
摘要:Let’s say we have a bank. Our bank wants to give each account for each user a unique name, for instance, “Personal” or “Checking.” How can we make sur
阅读全文
摘要:How can we see a histogram of movies on IMDB with a particular rating? Or how much movies grossed at the box office each month? Or how many movies the
阅读全文
摘要:Delete example: Update example:
阅读全文
摘要:We have all this data, but how do we answer questions about it? In this lesson we’ll learn how to filter down to just the information we’re looking fo
阅读全文
摘要:// Insert one row INSERT INTO movies (title, release_date, count_stars, director_id) VALUES ( 'Kill Bill', '10-10-2003', 3, 1 ); // Insert multi rows INSERT INTO movies (title, release_...
阅读全文
摘要:Learn how to create a table using the most widely-used data types (serial, varchar, integer, float, boolean, and date), and the most necessary constra
阅读全文