0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQL create databases ~ メモ

Posted at

データベース作成

CREATE DATABASE データベース名 default character set utf8;

default character set utf8 は 「utf8という文字コードでデータを保存する」

データベース操作

//データベースの一覧確認
show databases;

//データベースの削除するとき
DROP DATABASE データベース名;

テーブルの作成

「use データベース名;」でデータベースに移動する

CREATE TABLE テーブル名 (
    id INT,
    name VARCHAR(255)
);

()内で必要なカラムを記述する

コマンドプロンプトに直接入力せずファイル(.sql)に保存し実行する方法

ファイルに


CREATE DATABASE データベース名 default character set utf8;//データベースを作成する文

use データベース名;//データベースに切り替え

CREATE TABLE テーブル名 (
    id INT,
    name VARCHAR(255)
);//テーブルの作成

ファイルを実行

mysql> source ~ファイルパス/保存したファイル名.sql
を実行すればできる
注意 ファイルパスの「¥」マークのままではできないので「/」に書き換える必要があります

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?