https://cafe.naver.com/thisismysql

 

이것이MySQL이다 : 네이버 카페

한빛미디어 [이것이 MySQL이다] 카페입니다.

cafe.naver.com

 

위의 링크를 타고 글에 있는 이 링크를 클릭

 

https://drive.google.com/drive/folders/1KNAvefMzJpAurCj42-kTQmIoOvUTOe4T

 

10278_이것이 MySQL이다(2판) - Google Drive

이 폴더에 파일이 없습니다.이 폴더에 파일을 추가하려면 로그인하세요.

drive.google.com

 

movies 를 설치 후

 

 

해당 폴더들을 만들고 넣어준다.

 

그럼 이제 시작을 하기 위해한 자료들은 준비가 된 것이다.

 

이제 켜져있는 워크벤치를 꺼준다.

 

그 후 위와 같은 명령들로 해당 파일에 접근

 

여기서 수정해야 할 곳은 2개가 있다.

 

동영상을 업로드하기 위해 용량을 바꿔주는 것과

 

 

 

my.ini 파일을 저장후

net stop mysql을 하면 잠시 후 정지가 되고

net start mysql을 하면 다시 실행이 된다.

 

그리고 나서 워크 벤치를 키고 접속을 하면 적용이 된다.

 

CREATE DATABASE movieDB;

USE movieDB;
CREATE TABLE movietbl
(movie_id INT,
movie_title VARCHAR(30),
movie_director VARCHAR(20),
movir_star VARCHAR(20),
movie_script LONGTEXT,
movie_film LONGBLOB)
DEFAULT CHARSET = utf8mb4;

INSERT INTO movietbl VALUES (1,'쉰들러 리스트', '스필버그', '리암 니슨',
LOAD_FILE('C:/SQL/Movies/Schindler.txt'),
LOAD_FILE('C:/SQL/Movies/Schindler.mp4'));

SELECT * FROM movietbl;

SHOW variables LIKE 'max_allowed_packet';

SHOW variables LIKE 'secure_file_priv';

use moviedb;
TRUNCATE movietbl;
INSERT INTO movietbl VALUES (1, '쉰들러 리스트', '스필버그', '리암 니슨',
load_file('C:/SQL/Movies/Schindler.txt'), load_file('c:/sql/movies/Schindler.mp4'));
insert into movietbl values(2, '쇼생크 탈출', '프랭크 다라본트', '팀 로빈스',
load_file('c:/sql/movies/Shawshank.txt'), load_file('c:/sql/movies/Shawshank.mp4'));
insert into movietbl values(3, '라스트 모히칸', '마이클 만', '다니엘 데이 루이스',
Load_file('c:/sql/movies/mohican.txt'),load_file('c:/sql/movies/mohican.mp4'));

SELECT movie_script from movietbl where movie_id =1
INTO OUTFILE 'c:/sql/movies/schindler_out.txt'
LINES TERMINATED BY '\\n';

SHOW VARIABLES LIKE 'secure_file_priv';
SELECT * FROM movietbl;

use moviedb;
SELECT movie_film from movietbl where movie_id=3
into dumpfile 'c:/sql/movies/Mohican.mp4';

use sqldb;
create table pivottest
(uName CHAR(3),
season CHAR(2),
AMOUNT INT);
insert into pivotTest VALUES
('김범수', '겨울', 10), ('윤종신', '여름', 15), ('김범수', '가을', 25), ('김범수', '봄', 3),
('김범수', '봄', 37), ('윤종신', '겨울', 40), ('김범수', '여름', 14), ('김범수', '겨울', 22),
('윤종신', '여름', 64);

select * from pivotTest;

SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'sqldb' -- 여기에 데이터베이스 이름을 지정하세요
  AND TABLE_NAME = 'pivotTest'; -- 여기에 테이블 이름을 지정하세요

select uName,
	SUM(IF(season = '봄', amount, 0)) as '봄',
    sum(if(season = '여름', amount, 0)) as '여름',
    SUM(IF(season = '가을', amount, 0)) as '가을',
    SUM(IF(season = '겨울', amount, 0)) as '겨울',
    sum(amount) as '합계' from pivottest group by uName;
    
SELECT
    season,
    SUM(IF(uName = '김범수', amount, 0)) AS '김범수',
    SUM(IF(uName = '윤종신', amount, 0)) AS '윤종신'
FROM
    pivottest
GROUP BY
    season;

use sqldb;
SELECT JSON_OBJECT('name', name, 'height', height) as 'json 값'
from usertbl
where height >= 180;

SET @json = '{
    "usertbl": [
        {"name": "임재범", "height": 182},
        {"name": "이승기", "height": 182},
        {"name": "성시경", "height": 186}
    ]
}';

SELECT @JSON;

SELECT JSON_VALID(@JSOON) AS JSON_VALID;
SELECT JSON_SEARCH(@json, 'one', '성시경') AS JSON_SEARCH; -- 여기서 one대신에 all사용가능한데 one은 앞에 있는것 1개를 지칭
SELECT JSON_EXTRACT(@json, '$.usertbl[2].name') as JSON_EXTRACT;
SELECT JSON_INSERT(@json, '$.usertbl[0].mDate', '2009-09-09') AS JSON_INSERT;
SELECT JSON_REPLACE(@json, '$.usertbl[0].name', '홍길동') AS json_replace;
select json_remove(@json, '$.usertbl[0]') AS JSON_REMOVE;



-- JOIN
use sqldb;

SELECT *
FROM buytbl
INNER JOIN usertbl ON buytbl.userid = usertbl.userid
WHERE buytbl.userid = 'jyp';

select *
from buytbl
inner join usertbl
on buytbl.userid = usertbl.userid
order by num;

-- 이렇게하면 userid가 모호해져서 오류가 난다.
select userid, name, prodname, addr, concat(mobile1, mobile2) as '연락처'
from buytbl
inner join usertbl
on buytbl.userid = usertbl.userid
order by name;

select buytbl.userid, name, prodname, addr, concat(mobile1, mobile2) as '연락처'
from buytbl
inner join usertbl
on buytbl.userid = usertbl.userid
order by name;

-- 011-xxx-xxxx로 바꾸기
set @mobile1 = '011';
set @mobile2 = '2222222';
select concat(@mobile1, @mobile2);
-- case1
SELECT CONCAT(@mobile1, '-', left(@mobile2,3),'-', right(@mobile2,4));
-- case2
SELECT CONCAT(@mobile1, '-', SUBSTRING(@mobile2, 1, 3), '-', SUBSTRING(@mobile2, 4)) AS formatted_mobile;

오류 또는 에러 또는 버그

 

프로그램이 얘기치 않게 동작하게 만드는 프로그램안의 실수 또는 결함

 

디버그, 디버깅이란?

 

프로그램에서 버그를 제거하는 과정

 

 

 

 

오류의 종류

 

Syntax Error : 구문 오류

 

잘못된 문법의 사용으로 발생하는 오류

구문 오류는 컴파일 과정에서 검사 되기 때문에

오류를 수정하지 않으면 실행 불가

; 빠짐

 

} 빠짐

 

 

 

 

Logical Error : 논리 오류

 

프로그램이 부정확하게 동작하게 하지만

비정상적으로 종료 또는 충돌시키지는 않는 버그

계산식 안에 ( ) 가 생략됨

 

 

 

 

 

Run-time Error : 실행 오류

 

구문 오류도 논리 오류도 아니지만

프로그램이 실행 시 오류가 생겨 종료 됨

(즉, 프로그램이 비정상적인 동작 또는 종료)

ex) 0으로 나누기, 없는 파일 접근 하기 등

 

오류의 내용과 해당 줄을 알려줌

 

'Study > C#' 카테고리의 다른 글

[C#] 상수  (0) 2024.05.25
[C#] Var 키워드  (0) 2024.05.25
[C#] 컴파일과 빌드  (0) 2024.05.24
[C#] 주석  (0) 2024.05.24
[C#] 데이터 타입 bool, char, object  (0) 2024.05.24

<예시 이미지>

이미지 예시

 

1. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Hand Axe";
            string weaponType = "Axe";
            float DamagePerSecond = 3.2f;
            int minDamage = 2;
            int maxDamage = 3;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

 

 

1. 출력

 

2. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Aidan's Revenge";
            string weaponType = "Axe";
            float DamagePerSecond = 10.4f;
            int minDamage = 6;
            int maxDamage = 10;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

2. 출력

 

3. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Weathered Hand Axe";
            string weaponType = "Axe";
            float DamagePerSecond = 3.0f;
            int minDamage = 2;
            int maxDamage = 3;
            float AttacksPerSecond = 1.20f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

3. 출력

 

4. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Broad Axe";
            string weaponType = "Axe";
            float DamagePerSecond = 7.1f;
            int minDamage = 4;
            int maxDamage = 7;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

4.  출력

 

5. 코드

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Heavy Axe";
            string weaponType = "Axe";
            float DamagePerSecond = 17.5f;
            int minDamage = 10;
            int maxDamage = 17;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

5. 출력

 

6. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Marauder Axe";
            string weaponType = "Axe";
            float DamagePerSecond = 26.6f;
            int minDamage = 15;
            int maxDamage = 26;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

6. 출력

 

7. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Toporok";
            string weaponType = "Axe";
            float DamagePerSecond = 101.4f;
            int minDamage = 55;
            int maxDamage = 101;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

7. 출력

 

8. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Masakari";
            string weaponType = "Axe";
            float DamagePerSecond = 118.3f;
            int minDamage = 64;
            int maxDamage = 118;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

8. 출력

 

9. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Tomahawk";
            string weaponType = "Axe";
            float DamagePerSecond = 129.3f;
            int minDamage = 70;
            int maxDamage = 129 ;
            float AttacksPerSecond = 1.30f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

9. 출력

 

10. 코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20240124
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string weaponName = "Two-Handed Club";
            string weaponType = "Two-Handed Mace";
            float DamagePerSecond = 15.8f;
            int minDamage = 17;
            int maxDamage = 18 ;
            float AttacksPerSecond = 0.90f;

            Console.WriteLine(weaponName);
            Console.WriteLine(weaponType);
            Console.WriteLine(DamagePerSecond);
            Console.WriteLine("Damage Per Second");
            Console.WriteLine("{0}-{1} Damage", minDamage, maxDamage);
            Console.WriteLine($"{AttacksPerSecond:F2} Attacks Per Second");
        }
    }
}

 

10. 출력

'산대특 > 게임 알고리즘' 카테고리의 다른 글

C# 대리자, 람다함수  (1) 2024.01.31
Git, SourceTree  (1) 2024.01.31
CatEscape 게임  (2) 2024.01.30
멤버 변수와 지역 변수  (0) 2024.01.29
유니티 실행 시 인터페이스  (0) 2024.01.25

+ Recent posts