[데이터베이스]/Mega-MySQL
Day01. MySQL 설치와 수업 쿼리문
완벽한 장면
2023. 6. 15. 00:26
수업 자료(ppt)
Database
- 중복이 있다. 최소화할 뿐.
- DB에서는 마지막에 저장된 것이 가장 정확한 것이다.
수업 쿼리
SELECT * FROM producttbl;
select memberName, memberAddress from membertbl;
select * from membertbl where memberName = '지운이';
select memberAddress from membertbl where memberName ='지운이'; /*지운이의 주소만 출력*/
CREATE TABLE `my TestTBL` (id INT); /*테이블 생성 백틱*/
DROP TABLE `my TestTBL`; /*테이블 삭제*/
select * from producttbl where productName ='세탁기'; /*productTBL에 있는 세탁기 정보가 출력*/
CREATE TABLE indexTBL (first_name varchar(14), last_name varchar(16), hire_date date);
INSERT INTO indexTBL
SELECT first_name, last_name, hire_date
FROM employees.employees
LIMIT 500;
SELECT * FROM indextbl;
SELECT * FROM indextbl WHERE first_name = 'Mary';
CREATE INDEX idx_indexTBL_firstname ON indexTBL(first_name); /*인덱스로 만들기*/
/*idx_indexTBL_firstname 이게 인덱스 이름, 변수명 // 0.35초로 단축*/
CREATE VIEW uv_memberTBL
AS
SELECT memberName, memberAddress FROM memberTBL;
SELECT * FROM uv_membertbl; /*memberID는 나오지 않는다.*/
SELECT * FROM membertbl Where memberName = '당탕이';
select * from producttbl where productName = '냉장고';
DELIMITER //
CREATE PROCEDURE myProc()
BEGIN
SELECT * FROM memberTBL WHERE memberName = '당탕이' ;
SELECT * FROM productTBL WHERE productName = '냉장고' ;
END //
DELIMITER ;
CALL myProc() ; /*호출*/
MySQL 설치 방법
데이터베이스
데이터 중복의 최소화시킴 - 아예 없진 않음
mysql -u root -p //mysql연동(비밀번호 치고 들어감)
source @@@.sql //sql소스 업로드
728x90
반응형