【SQL】如何在 pgAdmin 上使用 DDL 快速初始化資料表

【SQL】如何在 pgAdmin 上使用 DDL 快速初始化資料表

前言當接觸到 PostgreSQL 後 pgAdmin 應該是最常被找到的一個免費 GUI 工具,雖然因為是網站的緣故,很多體驗與桌面版稍嫌落差(跟 postwomen 之餘 postman 一樣),但今天會告訴大家一個滿好用的功能 - DDL,而 DDL 在其他工具上(如 Navicat)上就讓我找不到地方使用,接著就帶大家認識一下 DDL 並透過 pgAdmin 講解使用的過程 🙂

前言

當接觸到 PostgreSQL 後 pgAdmin 應該是最常被找到的一個免費 GUI 工具,雖然因為是網站的緣故,很多體驗與桌面版稍嫌落差(跟 postwomen 之餘 postman 一樣),但今天會告訴大家一個滿好用的功能 - DDL,而 DDL 在其他工具上(如 Navicat)上就讓我找不到地方使用,接著就帶大家認識一下 DDL 並透過 pgAdmin 講解使用的過程 🙂

流程

接下來文章會按照下圖的步驟去說明:

簡單來說 資料定義語言(Data Definition Language,DDL)是屬於 DBMS 語言的一種,用於定義 DB schema,且 DBMS 內基本上都有 DDL 編譯器 (complier) 能夠處理 DDL,而它是由 CREATE、ALTER 與 DROP 三個語法所組成。

參考來自 wiki

操作環境

以下是我操作的環境,使用 docker-compose 幫我架起 postgreSQL & pgAdmin

步驟介紹

1. 建立範例 Table

首先先到 pgAdmin 中,建立一個新的 Table

建立一個範例的 Item table

再來是 Book table

簡單加個 Item 的外鍵 (Foreign Key)

[object object] [object object] [object object] [object object] sql

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Find Ulimit For user on Linux

Explains how to find ulimit values of currently running process or given user account under Linux using the 'ulimit -a' builtin command.

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

MEAN Stack Tutorial MongoDB ExpressJS AngularJS NodeJS

MEAN Stack Tutorial MongoDB ExpressJS AngularJS NodeJS - We are going to build a full stack Todo App using the MEAN (MongoDB, ExpressJS, AngularJS and NodeJS). This is the last part of three-post series tutorial.

Creating RESTful APIs with NodeJS and MongoDB Tutorial

Creating RESTful APIs with NodeJS and MongoDB Tutorial - Welcome to this tutorial about RESTful API using Node.js (Express.js) and MongoDB (mongoose)! We are going to learn how to install and use each component individually and then proceed to create a RESTful API.

systemctl List All Failed Units/Services on Linux

Explains how to use the systemctl command to list all failed units or services on Debian, Ubuntu, CentOS, Arch, Fedora, and other Linux distros.