티스토리 뷰
mysql 테이블 insert 실습
mysql 데이터베이스에서 어떤 테이블이 있는지 확인하기.
show tables;
MariaDB [opentutorials]> show tables;
+-------------------------+
| Tables_in_opentutorials |
+-------------------------+
| topic |
+-------------------------+
1 row in set (0.00 sec)
mysql 테이블 구조 확인하기.
desc topic;
MariaDB [opentutorials]> desc topic;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | 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 | |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.02 sec)
mysql에서 데이터 추가하기 insert 문 실습 (id는 자동증가하므로 쓸필요 없음).
MariaDB [opentutorials]> insert topic(title, description,created,author,profile) values('mysql','mysql is...',now(),'egoing','developer');
Query OK, 1 row affected (0.07 sec)
mysql에서 데이터가 제대로 추가됐는지 확인하기.
MariaDB [opentutorials]> select * from topic;
+----+-------+-------------+---------------------+--------+-----------+
| id | title | description | created | author | profile |
+----+-------+-------------+---------------------+--------+-----------+
| 1 | mysql | mysql is... | 2018-09-21 21:26:22 | egoing | developer |
+----+-------+-------------+---------------------+--------+-----------+
1 row in set (0.00 sec)
insert문을 이용하여 다음과 같이 생성해보자
+----+------------+------------------+---------------------+--------+-------------------------+
| id | title | description | created | author | profile |
+----+------------+------------------+---------------------+--------+-------------------------+
| 1 | mysql | mysql is... | 2018-09-21 21:26:22 | egoing | developer |
| 2 | orcle | orcle is.. | 2018-09-21 21:30:37 | egoing | devloper |
| 3 | sql server | sql server is... | 2018-09-21 21:32:08 | duru | data administator |
| 4 | postsql | postsql is... | 2018-09-21 21:36:45 | taeho | data scientist devloper |
| 5 | mongodb | mongdb is.. | 2018-09-21 21:37:55 | egoing | devloper |
+----+------------+------------------+---------------------+--------+-------------------------+
5 rows in set (0.00 sec)
'프로그래밍 > C#' 카테고리의 다른 글
mysql update 문 실습 (0) | 2018.09.21 |
---|---|
mysql select문 실습 (0) | 2018.09.21 |
mysql 테이블 생성하기 (0) | 2018.09.21 |
mysql 데이터베이스 생성 기본명령어 (0) | 2018.09.21 |
라즈베리파이에서 mysql 접속하기 (0) | 2018.09.21 |