--커뮤니티 테이블 생성
create table myboard(
	idx int not null auto_increment,
	memID varchar(20) not null,  
	title varchar(100) not null,
	content varchar(2000) not null,
	writer varchar(30) not null,
	indate datetime default now(),
	count int default 0,
	primary key(idx)
);


insert into myboard(title,content,writer)
values('게시판 연습','게시판 연습','관리자');

insert into myboard(title,content,writer)
(select title, content, writer from myboard);

select * from myboard order by idx desc;

select count(*) from myboard;

delete from myboard;
drop table myboard;


--공지사항 테이블 생성
create table myNotice(
	idx int not null auto_increment,
	memID varchar(20) not null,  
	title varchar(100) not null,
	content varchar(2000) not null,
	writer varchar(30) not null,
	indate datetime default now(),
	count int default 0,
	primary key(idx)
);

insert into myNotice(title,content,writer)
values('게시판 연습','게시판 연습','관리자');

insert into myNotice(title,content,writer)
(select title, content, writer from myNotice);

select * from myNotice order by idx desc;

select count(*) from myNotice;

delete from myNotice;
drop table myNotice;


-- 스프링 Security(회원테이블) --
create table mem_stbl(
	memIdx int not null, 
	memID varchar(20) not null,  
	memPassword varchar(68) not null,
	memName varchar(20) not null,
	memTel int,
	memEmail varchar(50),
	memAddr varchar(50),
	primary key(memID)
);

create table mem_auth(
	no int not null auto_increment,
	memID varchar(50) not null,
	auth varchar(50) not null,
	primary key(no),
	constraint fk_member_auth foreign key(memID) references mem_stbl(memID)
);

select * from mem_stbl;
select * from mem_auth;

delete from mem_stbl;
delete from mem_auth;

drop table mem_stbl;
drop table mem_auth;

