728x90
C:\APM_Setup\Server\MySQL\bin>mysql -uyou -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 to server version: 4.0.18-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use your_db; Database changed mysql> show tables; Empty set (0.00 sec)
들어가 봅시당.
먼저 사용할 db에 접속 후 table을 확인해줍니다. 아직 아무것도 없는 것을 확인할 수 있습니다.
mysql> create table student (num int, name char(10), adress char(40), tel char(20), primary key(num));
Query OK, 0 rows affected (0.03 sec)
mysql> insert student (num,name,adress,tel) values('1', '김형주', '인천 인하로', '032-119');
Query OK, 1 row affected (0.06 sec)
mysql> select * from student;
+-----+--------+-------------+---------+
| num | name | adress | tel |
+-----+--------+-------------+---------+
| 1 | 김형주 | 인천 인하로 | 032-119 |
+-----+--------+-------------+---------+
1 row in set (0.01 sec)먼저 이름이 student 인 table을 만들어줍니다. 그리고 필드명(num,name,adress,tel) 과 데이터 타입을 기록해줍니다. (첫번째 줄)
그리고 insert~ values 구문을 사용해 테이블에 들어갈 데이터들을 입력해줍니다.
select 문을 이용해 데이터가 잘 들어간 모습을 볼 수 있습니다.
같은 방법으로 몇 개 더 해주면
mysql> insert student (num,name,adress,tel) values('2', '이유진', '경기도 수원시', '031-419');
Query OK, 1 row affected (0.00 sec)
mysql> insert student (num,name,adress,tel) values('3', '김정연', '경기도 성남시', '031-222');
Query OK, 1 row affected (0.00 sec)
mysql> insert student (num,name,adress,tel) values('4', '박준', '서울시 관악구', '032-106');
Query OK, 1 row affected (0.00 sec)
mysql> select * from student;
+-----+--------+---------------+---------+
| num | name | adress | tel |
+-----+--------+---------------+---------+
| 1 | 김형주 | 인천 인하로 | 032-119 |
| 2 | 이유진 | 경기도 수원시 | 031-419 |
| 3 | 김정연 | 경기도 성남시 | 031-222 |
| 4 | 박준 | 서울시 관악구 | 032-106 |
+-----+--------+---------------+---------+
4 rows in set (0.00 sec)
예쁘게 들어간 모습을 볼 수 있습니다.
※ 만약 database 를 잘못 생성해 지우고싶다면,
drop database 데이터베이스명;
입력해주시면 됩니다.
'RDB > MySQL' 카테고리의 다른 글
| mysql 기본 명령어, 기본 함수 (0) | 2021.01.21 |
|---|---|
| php로 작성 , Mysql과 연동 (성적입력 홈페이지) (0) | 2021.01.21 |
| MySQL 실습 (3) - 필드 추가,삭제,데이터 변경. desc,alter,drop,where (0) | 2021.01.14 |
| MySQL 기초 실습 (1) - 계정 생성하기 select,create 등 (0) | 2021.01.13 |