XMRHRX
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
--- title: 1/4 資料庫環境配置 & 基本 SQL --- ## 資料庫環境配置 & 基本 SQL ### 2021/3/3 王子軒 ``` 開源 入土 拖魚羹 ``` <!-- 1.資料庫環境配置 & 基本 SQL SELECT UPDATE --> NOTE:今天要來教資料庫和SQL,幹訓有講過一些,有人還記得什麼是sql、什麼是資料庫嗎? --- ## 還記得..... ##### SELECT? 資料庫是啥? SQL可以幹麻? NOTE:今天要來教資料庫和SQL,幹訓有講過一些,有人還記得什麼是sql、什麼是資料庫嗎? ---- ## 資料庫(database) ```資料庫,簡而言之可視為電子化的檔案櫃——儲存電子檔案的處所,使用者可以對檔案中的資料執行新增、擷取、更新、刪除等操作...blablabla...``` ---- #### 像是一個櫃子(database),裡面裝了好多資料夾(表、table) ![](https://i.imgur.com/MWgpTaQ.png) ---- ## table??(資料表) #### 一個資料表,裡面有好多資料 ![](https://i.imgur.com/rE2Bols.png) ---- ## SQL? #### ***S*** tructured ***Q*** uery ***L*** anguage > a domain-specific language > designed for managing data ~~阿就拿來讓資料庫處理資料的語言啦ˋˊ~~ NOTE: 但是資料庫其實有很多種,例如:關係式資料庫,物件導向資料庫等等,SQL基本上是用在關係式資料庫。SQL也是我們課程主要要講的,我們寫的、送給資料庫跑得就叫做query --- ### 環境配置 http://sqlitestudio.pl/ https://github.com/QtTutorial/QtBasic/blob/master/Qt%20Sqlite/Taiwan (教學文章:https://chenglearning.blogspot.com/2013/11/sqlitestudio1sqlite.html) NOTE:下載這兩個 ---- ### 匯入Database 1. 按下 "&Add a database(Ctrl+O)" ![](https://i.imgur.com/RJw6boK.png) ---- 2. 按下 "Browsing for existing database file..." ![](https://i.imgur.com/W7b9XYC.png) ---- 3. 改成 "All files(*)" ![](https://i.imgur.com/uquD6em.png) ---- 4. 選剛剛下載的Taiwan,然後按 "OK" ![](https://i.imgur.com/uhAjkWN.png) ---- 5. 按下 "Open SQL &editor(Alt+E)" ![](https://i.imgur.com/YXNdP1L.png) --- ## query time! ---- ### 查詢 > https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all ``` SELECT <column1, column2,...> [FROM <table>][WHERE <condition>] ``` NOTE:把資料庫的資料查詢(選)出來。這邊有個用法,如果你想選所有欄位,可以用萬用字元* ---- ### row, column, cell補充 ![](https://i.imgur.com/BTkxsFa.png) ---- ### 查詢條件WHERE ``` 1. WHERE ID > 5 2. WHERE username = "Bob" OR username = "Alice" 3. WHERE uesrname != "Tom" ``` > SELECT * FROM customer > WHERE uesrname != "Tom" NOTE:後面的condition就是對欄位的判斷,很像其他程式語言對變數的判斷,基本的有大於、小於、等於、不等於、AND、OR。 --- ### 語法很怪很難記? 資料庫的概念比較像是"集合",所以如果用圖像的方式來想,語法上就會比較好記憶。 ![](https://i.imgur.com/NihHVbU.png) NOTE:例如select就是從中間選出、WHERE像是上面得某個範圍、地點 ---- ### 練習 > https://www.hackerrank.com/domains/sql?filters%5Bsubdomains%5D%5B%5D=select <!-- ================================== --> --- ### 修改 ``` UPDATE <table> SET <column>=<value>[, column2=value2, column3=value3...] [WHERE <condition>] ``` --- ### 欄位型態概念 NOTE: 資料庫儲存的時候,每個欄位都有對應的型態,像是C++、C、Java那樣,在處理資料庫的時候,例如:新增、修該和查詢條件,欄位要遇到值的時候都要注意欄位型態。 ---- ### 數值 ![](https://i.imgur.com/dorVcL5.png) ---- ### 浮點數 ![](https://i.imgur.com/253Iqf4.png) ---- ### 字串 ![](https://i.imgur.com/U0FzEQA.png) ---- ### 時間&日期 ![](https://i.imgur.com/04xztp6.png) ---- ### 練習 NOTE:因為更新沒有題目可以練習,接下來就在剛剛安裝的環境下測試。 ---- 1. 把台南City_Code改成1337 2. 把City_Code<100的City_cname改成天龍國 ---- <!-- 1.資料庫環境配置 & 基本 SQL TABLE SELECT UPDATE https://dbdiagram.io/home 2.基本SQL & 概念 Index, pri key INSERT DELETE DROP 3.進階 SQL & SQL 查詢練習/挑戰 INNER JOIN UNION SELECT 4.SQL床位異動練習 or SQL injection security injection -->

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully