SQL 2020. 4. 14. 19:18

DISTINCT 연산자

SELECT 문의 결과 값에서 특정 컬럼만 출력할 경우 중복된 값들이 나오는 경우에 이를 제거해서 표시하는 기능

SELECT DISTINCT 컬럼명 1, 컬럼명 2, ... FROM 테이블명

 

예제

- 국가코드가 'KOR' 인 도시들의 국가코드를 표시하시오.

- 국가코드가 'KOR' 인 도시들의 국가코드를 중복제거해서 표시하시오.

 

결과 확인

- SELECT CountryCode FROM city WHERE CountryCode = 'KOR';

- SELECT DISTINCT CountryCode FROM city WHERE CountryCode = 'KOR';

 

 

 

 

논리연산자 (AND, OR, NOT)

SELECT 문의 조건절에 논리 조건 적용해서 적용할 수 있는 연산자

SELECT * FROM 테이블명 WHERE (NOT) 조건 1 AND/OR (NOT) 조건 2 ..... 

 

예제

- 국가코드가 'KOR' 이면서 인구가 100만 이상인 도시를 찾으시오

- 국가코드가 'KOR', 'CNN', 'JPN' 인 도시를 찾으시오

- 국가코드가 'KOR' 이 아니면서 인구가 100만 이상인 도시를 찾으시오.

 

 

 

결과 확인

- SELECT * FROM city WHERE CountryCode = 'KOR' AND Population > 1000000

- SELECT * FROM city WHERE CountryCode = 'KOR' OR CountryCode = 'CNN' OR CountryCode = 'JPN'

- (위와 같은 코드) SELECT * FROM city WHERE CountryCode in ('KOR', 'CNN', 'JPN')

 

- SELECT * FROM city WHERE CountryCOde != 'KOR' AND Population > 1000000

posted by 핵커 커뮤니티
:
SQL 2020. 4. 14. 19:17

SQL (Structured Query Language) :

     - 관계형 데이터베이스에서 사용하는 표준 질의언어를말한다.

     - 사용 방법이나 문법이 다른 언어(Java, C, C#, Java)보다 단순하다.

     - 모든 DBMS에서 사용 가능하다.

     - 인터프리터 언어

     - 대소문자 구별하지 않는다.

 

 

 

DML :

     - 데이터베이스의 테이블에 있는 내용을 직접 조작하는 기능

     - 테이블의 레코드를 CRUD (Create, Retrieve, Update, Delete)

 

SQL 문

내용

insert

데이터베이스 객체에데이터를 입력

delete

데이터베이스 객체에데이터를 삭제

update

데이터베이스 객체 안의데이터 수정

select

데이터베이스 객체 안의데이터 조회

 

 

DDL :

     - 데이터베이스의 스키마를 정의, 생성, 수정하는 기능

     - 테이블 생성, 컬럼 추가, 타입 변경, 각종 제약조건 지정,수정 등

 

SQL 문

내용

create 

데이터베이스 객체를생성

drop

데이터베이스 객체를삭제

alter

기존에 존재하는데이터베이스 객체를다시 정의

 

 

DCL :

     - 데이베이스의 테이블에 접근 권한이나 CRUD 권한을 정의하는기능

     - 특정 사용자에게 테이블의 조회권한 허가 / 금지 등

 

SQL문

내용

grant

데이터베이스 객체에권한을 부여

revoke

이미 부여된데이터베이스 객체권한을 취소

 

CRUD (Create, Retrieve, Update, Delete) :

이름

조작

SQL

create 

read (retrieve)

생성

읽기 (인출)

insert

select

update

갱신

update

delete (destroy)

삭제 

delete

 

     Create : 데이터베이스 객체 생성     

          - insert into

          - 새로운 레코드를 추가

 

     Update : 데이터베이스 객체 안의 데이터 수정

          - update     

          - 특정 조건의 레코드의 컬럼 값을 수정

 

Delete : 데이터베이스 객체의 데이터 삭제

     - delete     

     - 특정 조건의 레코드를 삭제

 

Retrieve : 데이터베이스 객체 안의 데이터 검색

     - select     

     - 조건을 만족하는 레코드를 찾아 특정 컬럼 값(모두표시 *)을 표시

 

 

 

 

select 명령문 :

select 컬럼명 from 테이블명 where 조건절;

 

- "world" DB에서의 쿼리 예제

국가 코드가 'KOR' 으로 되어 있는 도시들의 이름을구하시오

select Name from city where CountryCode='KOR';

 

인구가 500만 이상인 도시들의 이름을 구하시오

select Name from city where Population > 5000000;

 

 

insert into 명령문 : 

insert into 테이블명 (컬럼명) values (값);

 

- 예제

# 각각의 필드와 대응 시켜줘서 insert 를 시켜주어야한다.

insert into city (ID, Name, CountryCode, District, Population) values (10000, "Sample", "KOR", "Test", 1000000);

 

# 이 경우에는 모든 컬럼 값들이 일일히 필드와대응되면 생략 가능

insert into city values (20000, "SampleTest", "KOR", "Test", 2000000);

 

- 결과 확인

# ID 가 100000 인 레코드 출력

select * from city where ID = 20000;

 

# ID 가 200000 인 레코드 출력

select * from city where ID = 10000;

 

 

 

 

update 명령문 : 

update 테이블명 set 컬럼명=값, ..... where 조건절;

 

- 예제

# ID 가 10000 인 레코드의 name 을"SampleRevised" 로 변경

update city set name = "SampleRevised" where id = 10000;

 

- 결과 확인

# ID 가 100000 인 레코드 출력

select * from city where ID = 10000;

 

 

delete 명령문 :

delete from 테이블명 where 조건절;

 

- 예제 

# ID 가 20000 이며 Population 이 2000000 인레코드를 삭제

delete from city where (ID = 20000) AND (Population = 2000000);

 

# ID 가 10000 이며 Population 이 1000000 인레코드를 삭제

delete from city where (ID = 10000) AND (Population = 1000000);

 

- 결과 확인

# ID 가 100000 인 레코드 출력

select * from city where ID = 10000;

 

# ID 가 200000 인 레코드 출력

select * from city where ID = 20000;

'SQL' 카테고리의 다른 글

[SQL] JOIN VIEW,별명알아보자  (0) 2020.04.14
[SQL] 일부결과 및 집합함수  (0) 2020.04.14
[SQL] 연산 논리 (기초 배우기 )  (0) 2020.04.14
[SQL] 설치하기 / 다운로드  (0) 2020.04.11
posted by 핵커 커뮤니티
:
C++ 2020. 4. 14. 19:09

#include "bigint\BigIntegerLibrary.hh" #include <afx.h> #include <iostream> #include <string.h> #import "winhttp.tlb" no_namespace named_guids char* wc2ansi(CStringW& unicodestr) { char *ansistr; int lenW = wcslen(unicodestr.GetString()); int lenA = WideCharToMultiByte(CP_ACP, 0, unicodestr, lenW, 0, 0, NULL, NULL); if (lenA > 0) { ansistr = new char[lenA + 1]; WideCharToMultiByte(CP_ACP, 0, unicodestr, lenW, ansistr, lenA, NULL, NULL); ansistr[lenA] = 0; } return ansistr; } VOID ansi2wc(char* ansistr, CStringW& Result) { int lenA = lstrlenA(ansistr); int lenW; BSTR unicodestr; lenW = ::MultiByteToWideChar(CP_ACP, 0, ansistr, lenA, 0, 0); if (lenW > 0) { // Check whether conversion was successful unicodestr = ::SysAllocStringLen(0, lenW); ::MultiByteToWideChar(CP_ACP, 0, ansistr, lenA, unicodestr, lenW); } Result = CStringW(unicodestr); return; } VOID SplitKey(CStringW& szSource, CStringW* KeyArr) { DWORD dwPos = 0, dwNextPos = 0, i = 0; dwNextPos = szSource.Find(L",", 0); // Mid의 시작 지점은 0임 do { KeyArr[i++].SetString(szSource.Mid(dwPos, dwNextPos - dwPos)); dwPos = dwNextPos + 1; dwNextPos = szSource.Find(L",", dwPos); }while(dwNextPos != -1); KeyArr[i].SetString(szSource.Mid(dwPos)); return; } PBYTE pkcs1pad2(CStringW& OrgText, int dwPadNum) { PBYTE Buffer = (PBYTE)malloc(dwPadNum); int padIndex = OrgText.GetLength() - 1; while( padIndex >= 0 ) Buffer[--dwPadNum] = ((PBYTE)OrgText.Mid(padIndex--, 1).GetString())[0]; Buffer[--dwPadNum] = 0; while( dwPadNum > 2) Buffer[--dwPadNum] = rand() % 256 + 1; Buffer[--dwPadNum] = 2; Buffer[--dwPadNum] = 0; return Buffer; } VOID Get16Times(BigInteger& Result, DWORD dwTimes) { Result = BigInteger(1); for(int i = 0; i < dwTimes; i++) { Result = Result * BigInteger(16); } return; } VOID RSAFastEncrypt(BigInteger& orgInt, BigInteger& exp, BigInteger& moduler, BigInteger& Result) { Result = orgInt % moduler; for(int i = 0; i < 16; i++) Result = Result * Result % moduler; Result = Result * orgInt % moduler; } int main() { CStringW szID(L"비밀번호"); CStringW szPW(L"아이디"); HRESULT hr = CoInitialize(0); if(SUCCEEDED(hr)){ IWinHttpRequestPtr IE; IE.CreateInstance(CLSID_WinHttpRequest); IE->Open(_bstr_t(L"GET"), _bstr_t(L"http://nid.naver.com/login/ext/keys.nhn")); IE->Send(); CStringW Buffer((wchar_t*)(IE->ResponseText)); CStringW KeyArr[4]; // 먼저 키를 나눈다 SplitKey(Buffer, KeyArr); // Original Text를 형성한다. CStringW OrgText; OrgText = OrgText + (char)KeyArr[0].GetLength(); OrgText = OrgText + KeyArr[0]; OrgText = OrgText + (char)szID.GetLength(); OrgText = OrgText + szID; OrgText = OrgText + (char)szPW.GetLength(); OrgText = OrgText + szPW; // 문자열을 Byte Array로 변환하고 PBYTE TextByteArr = (PBYTE)pkcs1pad2(OrgText, 128); BigInteger orgInt(0); BigInteger bigTimes; // Byte Array를 BigInteger로 치환한다. for(int i = 127; i >= 0; i--) { Get16Times(bigTimes, (127 - i) * 2); orgInt = orgInt + BigInteger(TextByteArr[i]) * bigTimes; } BigInteger Result(0); BigInteger eValue = stringToBigInteger(wc2ansi(KeyArr[2])); BigInteger nValue = stringToBigInteger(wc2ansi(KeyArr[3])); // 암호화를 진행한다. RSAFastEncrypt(orgInt, nValue, eValue, Result); // 이제 로그인을 진행하자 CStringW HeaderString, Converted; ansi2wc((char*)(bigUnsignedToString(Result.getMagnitude()).c_str()), Converted); HeaderString = HeaderString + "enctp=1"; HeaderString = HeaderString + "&encpw=" + Converted.MakeLower(); HeaderString = HeaderString + "&encnm=" + KeyArr[1]; HeaderString = HeaderString + "&svctype=0"; HeaderString = HeaderString + "&id="; HeaderString = HeaderString + "&pw="; HeaderString = HeaderString + "&x=35"; HeaderString = HeaderString + "&y=14"; IE->Open((_bstr_t)L"POST", (_bstr_t)L"https://nid.naver.com/nidlogin.login"); IE->SetRequestHeader((_bstr_t)L"Referer", (_bstr_t)L"http://static.nid.naver.com/login.nhn?svc=wme&url=http%3A%2F%2Fwww.naver.com&t=20120425"); IE->SetRequestHeader((_bstr_t)L"Content-Type", (_bstr_t)L"application/x-www-form-urlencoded"); IE->Send((_bstr_t)HeaderString); CStringW strResponse = (wchar_t*)IE->GetResponseText(); if( strResponse.Find(L"location.replace") != -1 ) std::cout << "로그인에 성공하였습니다." << std:

'C++' 카테고리의 다른 글

[C++] 로그인 프로그램 소스  (0) 2020.04.15
posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:07

[PHP]함수의 인수

함수 안에서 사용하는 값을 함수 밖에서 전달할 수 있는데 이 값을 인수라고 한다.

-예

<?php

function check($age) {

$result = (20 <= $age)?"프로":"그래밍";

print $result."입니다.";

}

check(19);

?>

-결과

​프로그래밍

 

인수가 지정되지 않은 경우(에러가 발생한다.)

- 예

<?php

function check($age) {

$result = (20 <= $age)?"프로":"그래밍";

print $result."입니다.";

}

check();

?>

- 결과(에러 발생)

Fatal error: Uncaught ArgumentCountError: Too fewargumenC:/ xampp/hydocs/for:php:

2 Stack trace: #0 C:xampp/hidocs/for

인수에 값이 없는 경우 에러가 발생하므로 인수의 기본값을 사용한다.

-예

<?php

function check($age=19) {

$result = (20 <= $age)?"프로":"그래밍";

print $result."입니다.";

}

check();

?>

 

- 결과(에러가 발생하지 않았다.)

프로그래밍

 

<?php

function test($x1, $x2)(

echo '*'.$x1.$x2.'*';

)

test('핵','커');

?>

결과는 *핵커*

'PHP' 카테고리의 다른 글

[PHP] PHP 문자 N 문자를 연결해보자!  (0) 2020.04.14
[PHP] PHP 함수 생성 및 호출  (0) 2020.04.14
[PHP] PHP 다운로드  (0) 2020.04.14
[PHP] 시작,종류,태그,변수,저장확정자  (0) 2020.04.11
posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:05

[PHP]문자와 문자를 연결하기

php에서는 문자와 문자를 연결시 + 대신에 .를 사용한다.

-입력

<?php

echo "*"."아이유";​

?>

-출력

아이유

 

html을 포함한 경우

-줄바꿈이 가능하다.

-입력

​<?php

echo "*"."아이"."</br>"."유2";

?>

-출력

결과

아이유

입력1

<?

$test = "너 ";

$test.= "랑";

$test.= "나";

print $test;

?>

결과

너 랑 나

'PHP' 카테고리의 다른 글

[PHP] PHP 함수의 인수 배우보자!!!  (0) 2020.04.14
[PHP] PHP 함수 생성 및 호출  (0) 2020.04.14
[PHP] PHP 다운로드  (0) 2020.04.14
[PHP] 시작,종류,태그,변수,저장확정자  (0) 2020.04.11
posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:03

[PHP]함수 생성 및 호출

다음은 모두 같은 의미이다.

- 작은 프로그램의 모음

- 서브루틴

- 사용자 정의 함수

사용자 정의 함수를 사용하면 같은 내용을 여러 번 사용할 때 간단히 함수를 불러오면 되서 편리하다.

정의

- function 함수명() {

​ 처리 내용;

}

사용

- 함수명();

* 함수의 정의와 함수의 사용 순서는 상관없다.

​예

<?php

function copyright() {

print "<font size=7>";

print "copyright all right reserved";

print "</font>";

}

copyright();

?>

<?php

fuction test()(

echo 1;

)

test();

?>

함수 실행 예1

<?php

test($x)(

echo $x;

)

test('hello world');

?>

함수 실행 예2

<?php

test($x)(

echo $x;

)

test('hello world');

test('hello jeju');

?>

함수 실행 예3

<?php

test($x)(

echo $x;

)

test('hello');

test('mr my);

test('yesterday);

?>

posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:01
 

PHP For Windows: Binaries and sources Releases

PHP 7.3 (7.3.16) Download source code [27.04MB] Download tests package (phpt) [14.25MB] VC15 x64 Non Thread Safe (2020-Mar-17 15:56:44) Zip [24.43MB] sha256: 61d9c8a85b8cfc84cd72ec754b9fa260c252fafdc7f82c9b835a9ec45353ab62 Debug Pack [23.08MB] sha256: f511

windows.php.net

 

 

posted by 핵커 커뮤니티
:
Olly_Dbg 2020. 4. 14. 18:55
 

OllyDbg v1.10

 

www.ollydbg.de

 

'Olly_Dbg' 카테고리의 다른 글

[올리디버거] 단축키 알아보자  (0) 2020.04.10
posted by 핵커 커뮤니티
: