/* 테이블 생성 */
create table [테이블명](컬럼명 컬럼타입(사이즈) 제약조건)옵션;
ex)
create table muser(
uid varchar(50) not null primary key,
username varchar(50) not null,
email varchar(50) not null,
createdate timestamp not null DEFAULT CURRENT_TIMESTAMP,
modifydate timestamp not null DEFAULT CURRENT_TIMESTAMP
)engine=innodb default charset=utf8
/* 테이블 삭제 */
drop table [테이블명];
/* 컬럼 추가 */
alter table [테이블명] add [컬럼명] [타입] [옵션];
ex) alter table [테이블명] add [컬럼명] varchar(32) not null default '0';
/* 컬럼 삭제 */
alter table [테이블명] drop [컬럼명];
/* 컬럼명 변경 */
alter table [테이블명] change [컬럼명] [변경할컬럼명] varchar(32);
/* 컬럼 타입 변경 */
alter table [테이블명] modify [컬럼명] 변경할 타입;
/* 테이블명 수정 */
alter table [테이블명] rename [변경할테이블명];
JDBC를 위한 설정
driver = "com.mysql.jdbc.Driver";
url = "jdbc:mysql://127.0.0.1:3306/데이터베이스이름?useSSL=false&useUnicode=true&characterEncoding=utf8";
username = "유저명";
password = "패스워드";
스프링에서 MyBatis 적용을 위한 설정(root-context.xml)
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/데이터베이스이름?useSSL=false&useUnicode=true&characterEncoding=utf8"></property>
<property name="username" value="유저명"></property>
<property name="password" value="패스워드"></property> -->
</bean>
'MySQL' 카테고리의 다른 글
| MySQL 처음 접속 해보기 (0) | 2021.07.13 |
|---|---|
| mysql 5.7 설치방법 (0) | 2017.01.27 |