惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
B
Blog
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
月光博客
月光博客
H
Help Net Security
V
Visual Studio Blog
量子位
A
About on SuperTechFans
博客园 - Franky
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Learning SQL from Scratch(2): Setup and Preparations
2022-06-04 · via jdhao's digital space
update log
  • 2022-10-12: add fake data generation website.
  • 2022-10-11: add TUI client for MySQL and Postgres.
  • 2022-09-24: add sample database we can try.

In this post, I will talk about setting up SQL databases and also the tools needed to write SQL queries.

Install and set up SQL#

MySQL install and setup#

Install using HomeBrew:

Start and stop the MySQL server:

brew services start mysql
brew services stop mysql

Connect to MySQL server in macOS#

  • Host: localhost
  • Port: 3306
  • Username: root

Postgres install#

Install using HomeBrew:

Start and stop the postgres server:

brew services start postgresql
brew services stop postgresql

Connect to postgres server in macOS#

  • Host: localhost
  • Database: postgres
  • Username: jdhao

No password is needed.

Try sql online#

If you do not want to install and just want to experiment with different SQL databases, there some several website where you can use the databases online:

Database to play with#

Sample database#

There are some sample databases with multiple tables so that we can toy with them easily.

Ref:

Generate fake data#

We can also use some online data generation tool to generate fake data:

I tried both and they work well.

TUI client#

You can use the MySQL and PostgreSQL executable to interact with databases on the command line. However, they do not support autocompletion or syntax highlighting. There are some 3rd party SQL client with auto-completion and syntax highlighting features:

  • mycli: TUI client for MySQL.
  • pgcli: TUI client for Postgres.

GUI client#

Most people will probably choose a GUI client to work with the databases.

Mysql workbench#

Mysql workbench is a GUI application to help us manage mysql server more easily.

Pgadmin#

If you use PostgreSQL, you can try Pgadmin 4, which is specifically built for Postgres. However, some people say the UX sucks.

Postico#

Postico is a lightweight tool built for Postgres. Simple interface, non-free, no auto-completion.

Datagrip#

Datagrip is developed my JetBrains and it is not free. It has support for all kinds of databases.

It has autocompletion for SQL keywords, functions, table names, and column names etc. Highly recommended, intelligent and very good user experience.

DBeaver#

DBeaver is an open source database client.

It also has autocompletion, but it is not as powerful as Datagrip.

Change keyword case in DBeaver: https://stackoverflow.com/a/60854946/6064933

BeeKeeper Studio#

BeeKeeper is another database client.

No autocompletion, very simple GUI, less features than DBeaver and Datagrip. Not recommended.

Table plus#

Table plus is a commercial product that supports a lot of databases. The interface is clean and easy to use.

Requires a license, otherwise very limited feature available.