iT邦幫忙

2024 iThome 鐵人賽

DAY 6
0

昨天安裝好了intellij Utimate,今天要來設定一些資料庫的東西~

第一步

記得要去MySQL Configurator啟動我們的資料庫,然後先創建一個新的database,可以用

show databases;

來查看目前我們有的資料庫,並使用

create database database1;

來創建一個名為"database1"的資料庫,之後檢查一下有沒有創建成功。
https://ithelp.ithome.com.tw/upload/images/20240920/20169406HxzT3pJpSj.png
看到多了一個database1就是成功囉!

創建成功之後要啟用資料庫,使用以下程式碼

use database1;

第二步

我們要創建一個table來存放資料,首先使用這段程式碼來看我們有的table

show tables;

因為我們還沒創建,所以table列表是空的

https://ithelp.ithome.com.tw/upload/images/20240920/20169406SvqehI9gYe.png

使用這段程式碼來創建一個table

create table student_information (number int primary key, name varchar(50), gender varchar(50), age int);

這個table總共有4項資料,分別是學號、姓名、性別、年齡,int只能輸入數字,varchar(50)是代表能夠輸入包括中文字的50個字元,創建完之後一樣使用

show tables;

來查看tables。
https://ithelp.ithome.com.tw/upload/images/20240920/20169406zBxGvTk7Kq.png
這樣就出現啦!

明天會來分享如何把資料寫入table中~~


上一篇
D5:開發環境安裝 Intellij Ultimate
下一篇
D7:資料庫寫入數據
系列文
資料庫與Java開發工具連接26
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言