MySQL

📌 SQL

-接続
cd /usr/local/mysql/bin
./mysql - uroot -p
-構造

스키마
にグループ化される.フォルダのことです.-使用モード
mysql> create DATABASE opentutorials; #만들기
mysql> SHOW DATABASES; #보여주기
mysql> USE opentutorials # 사용하기
-テーブルの作成
CREATE TABLE topic(
id INT(11) NOT NULL AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
description TEXT NULL,
created DATETIME NOT NULL,
author VARCHAR(30) NULL,
profile VARCHAR(100) NULL ,
PRIMARY KEY(id));
- CRUD
- create (insert)
USE 사용할데이베이스
INSERT INTO topic (title,description,created,author,profile) VALUES('mysql','my sql is...',NOW(),'egoing','developer');
SELECT * FROM topic; #확인
- select(read)
SELECT id,title,created, author FROM topic WHERE author="egoing";
SELECT id,title,created, author FROM topic WHERE author="egoing" ORDER BY id DESC;
- update
UPDATE topic SET description='ORACLE IS,,,,,,', title = "ORACLE" WHERE id=2; #id 값이 2인 행에 대해서
- delete
DELETE FROM topic WHERE ID = 5;
- Join
SELECT * FROM topic LEFT JOIN author ON topic.author_id = author.id; #전체
SELECT topic.id,title,description,created,name,profile FROM topic LEFT JOIN author ON topic.author_id = author.id;
# 전체에서 몇개 빼고 join
SELECT topic.id as topic_id,title,description,created,name,profile FROM topic LEFT JOIN author ON topic.author_id = author.id;
#첫번째 칼럼이 topic_id로 바뀜
「ライフコードMySQL」で学んだ内容をまとめました。Reference
この問題について(MySQL), 我々は、より多くの情報をここで見つけました https://velog.io/@byhazy/관계형-데이터-베이스テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol