본문 바로가기

Server/Mysql

Database, Table 생성

아주 기초적인 내용이지만 다시한번 포스팅합니다. 


mysql -u(계정) -p    (엔터입력)

Password: 


Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4382

Server version: 5.5.44 MySQL Community Server (GPL) by Remi


Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


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


mysql> 


위와 같이 mysql에 접속된 것을 확인 할 수 있다. 


mysql> create database newdatabase;

Query OK, 1 row affected (0.00 sec)


mysql> use newdatabase; #새로 생성된 데이터베이스를 사용한다. 

Database changed


자 이번엔 테이블을 생성해 보겠습니다. 

newTable이라는 이름을 가진 테이블을 생성합니다. 
각각 no, id, pw라는 필드를 가집니다. 속성은 용도에 맞게 적절하게 주시면 됩니다. 

create table newTable (

no varchar(50) null,

id int null,

pw varchar(50) null

)


테이블이 생성되었습니다.