TIL 06 : mysql_INSERT & SELECT
20899 ワード
SQL?
S == Structured
Q == Query
L == Language
クリーンアップ用語
表
-
-1つのデータ、1つのデータ自体
-
-データを表す構造
S == Structured
Q == Query
L == Language
クリーンアップ用語
表
-
row
,record==行-1つのデータ、1つのデータ自体
-
column
==列-データを表す構造
CREATE DATABASE opentutorials; #opentutorials라는 데이터베이스를 생성함
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| music |
| mysql |
| opentutorials | #여기에 있음!
| performance_schema |
| sys |
+--------------------+
USE opentutorials;
mysql> CREATE TABLE topic( #opentutorials에 topic 이라는 테이블을 생성함
-> id INT(11) NOT NULL AUTO_INCREMENT, #NOT NULL == 빈 공간이 없어야함, AUTO_INCREMENT == 자동으로 증가함
-> title VARCHAR(100) NOT NULL,
-> description TEXT NULL, #NULL = 빈 공간을 허용함
-> created DATETIME NOT NULL,
-> author VARCHAR(30) NULL,
-> profile VARCHAR(100) NULL
-> , PRIMARY KEY(id)); #중요한 키 == id
DESC topic; #테이블의 구조를 보여줌
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| title | varchar(100) | NO | | NULL | |
| description | text | YES | | NULL | |
| created | datetime | NO | | NULL | |
| author | varchar(30) | YES | | NULL | |
| profile | varchar(100) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
mysql> INSERT INTO topic (title,description,created,author,profile) VALUES('MySQL','MySQL is ...',NOW(),'egoing','developer');
mysql> SELECT * FROM topic; #creat한 것을 read하는 방법
+----+-------+--------------+---------------------+--------+-----------+
| id | title | description | created | author | profile |
+----+-------+--------------+---------------------+--------+-----------+
| 1 | MySQL | MySQL is ... | 2021-08-27 20:46:55 | egoing | developer |
+----+-------+--------------+---------------------+--------+-----------+
mysql> INSERT INTO topic (title,description,created,author,profile) VALUES('ORACLE','Oracle is ...',NOW(),'egoing','developer');
mysql> INSERT INTO topic (title,description,created,author,profile) VALUES('SQL Server','SQL Server is ...',NOW(),'duru','database administrator');
mysql> INSERT INTO topic (title,description,created,author,profile) VALUES('PostgreSQL','PostgreSQL is ...',NOW(),'taeho','data scientist, developer');
mysql> INSERT INTO topic (title,description,created,author,profile) VALUES('MongoDB','MongoDB is ...',NOW(),'egoing','developer');
mysql> SELECT * FROM topic;
+----+------------+-------------------+---------------------+--------+---------------------------+
| id | title | description | created | author | profile |
+----+------------+-------------------+---------------------+--------+---------------------------+
| 1 | MySQL | MySQL is ... | 2021-08-27 20:46:55 | egoing | developer |
| 2 | ORACLE | Oracle is ... | 2021-08-27 21:07:16 | egoing | developer |
| 3 | SQL Server | SQL Server is ... | 2021-08-27 21:13:50 | duru | database administrator |
| 4 | PostgreSQL | PostgreSQL is ... | 2021-08-27 21:15:49 | taeho | data scientist, developer |
| 5 | MongoDB | MongoDB is ... | 2021-08-27 21:16:03 | egoing | developer |
+----+------------+-------------------+---------------------+--------+---------------------------+
Reference
この問題について(TIL 06 : mysql_INSERT & SELECT), 我々は、より多くの情報をここで見つけました https://velog.io/@deep/TIL-06-mysqlINSERT-SELECTテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol