본문 바로가기

DB/MySql

mysql DB table 생성

mysql로 작업할때 였다. 
결론적으로 oracle로 작업했으나 혹시 필요할지도 모르겠다. 

[root@FMS14 ~]# mysqladmin -u root create javaga_board 
[root@FMS14 ~]# mysql -u root 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 10760 
Server version: 5.1.50 Source distribution 

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 
This software comes with ABSOLUTELY NO WARRANTY. This is free software, 
and you are welcome to modify and redistribute it under the GPL v2 license 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 

mysql> grant select, insert, update, delete, create, drop on javaga_board.* to 'mua2145'@'localhost' identified by 'gpgp2145'; 
Query OK, 0 rows affected (0.01 sec) 

[root@FMS14 ~]# mysql -u mua2145 -p javaga_board 
Enter password: 

-----> db 생성, 계정생성, 비번 및 권한 설정을 하고 접속까지 완료. 

mysql> create table BOARD ( 
BOARD_ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 
W_DATE TIMESTAMP NOT NULL, 
SUBJECT VARCHAR(30) NOT NULL, 
NAME VARCHAR(20) NOT NULL, 
COUNT INT, 
BODY_TXT MEDIUMTEXT NOT NULL 
); 
Query OK, 0 rows affected (0.02 sec) 

----------> 테이블 생성. 
mysql> INSERT INTO BOARD(BOARD_ID, W_DATE, SUBJECT, NAME, COUNT, BODY_TXT) VALUES('',now(),'test','mua2145','0','body test'); 
Query OK, 1 row affected, 1 warning (0.00 sec) 

mysql> select * from BOARD; 
+----------+---------------------+---------+---------+-------+-----------+ 
| BOARD_ID | REGISTER | SUBJECT | NAME | COUNT | BODY_TXT | 
+----------+---------------------+---------+---------+-------+-----------+ 
| 1 | 0000-00-00 00:00:00 | test | mua2145 | 0 | body test | 
+----------+---------------------+---------+---------+-------+-----------+ 
1 row in set (0.00 sec) 

--------> 테스트 데이터 삽입 및 확인. (중요한건 oracle과 달리 대소문자 구분한다.)
출처 : http://baeksupervisor.tistory.com/142


cnfcj :  [출처]
 mysql DB table 생성|작성자 촌철살인

'DB > MySql' 카테고리의 다른 글

[MySQL] Event Scheduler  (0) 2011.09.06
각종 함수  (0) 2011.08.23
MY SQL column type  (0) 2009.10.26