728x90

미디어쿼리

max-width

최대여기 영역까지 css적용!

 

*그래서 순서도 큰 영역에서 작은 영역으로 써줘야 적용이 된다!!!!!!!

(이런느낌)

  @media screen and (max-width: 1440px) {
   
  }
  @media screen and (max-width: 1024px) {
   
  }

  @media screen and (max-width: 400px) {
   
  }

 

최소영역은 반대

작은 영역에서 큰영역으로 순서 써야함..

 

중앙정렬

중앙정렬할 때 

마진 오토가 안먹혀서 뭔가 했더니 가로값을 주어야했다!!

 position: fixed;
  /* fixed를 쓸 때에는 width, height를 명시해줘야 한다. */
  width: 460px
  /* left, right는 해당 요소의 위치 시작점을 결정한다. 그런데, 이때, margin의 양 값을 auto로 줌으로써 마진을 주어 해당 요소의 양 끝 위치를 각각 0으로 만들어준다. */
  margin: 0 auto;
  left: 0;
  right: 0;

출처 :https://wansook0316.github.io/dv/html-css/2020/03/19/position-fixed-center-%EC%A0%95%EB%A0%AC.html

 

////

position

postion: fixed

position:relative

position:absolute

....

https://developer.mozilla.org/ko/docs/Web/CSS/position

 

display:plex

 

 

 

728x90

'프론트 > Html Css' 카테고리의 다른 글

margin 값 방향  (0) 2021.10.26
box-sizing: border-box;  (0) 2021.10.26
box-shadow  (0) 2021.10.26
구조 가상 클래스 only-child /nth-of-type(n)  (0) 2021.08.23
:target :checked/ input type="checkbox"/필수입력창  (0) 2021.08.22
728x90

yarn build시 에러

 Build optimization failed: found page without a React Component as default export in
pages/types

 

error Command failed with exit code 1.

 

 

페이지마다 export default ,

default를 기본으로 하는애가 있어야한다고 이해해서 

페이지 types에 없어서 그런가 해봤는데 해결안됨

오히려 타입안에 인터페이스에 default붙이니까 못읽음

 

 

 

 

찾아보다가 

 

 

구성 요소를 페이지 폴더 외부로 이동해야 합니다. Pages/ Next.js 라우팅이 구조를 기반으로 하므로 페이지 구성 요소에만 사용해야 합니다 

Next.js에는 페이지 개념을 기반으로 구축된 파일 시스템 기반 라우터가 있습니다. 

파일이 페이지 디렉토리에 추가되면 자동으로 경로로 사용할 수 있습니다. 

위의 동작이 기본 동작이지만 페이지 디렉토리에 페이지가 아닌 파일을 포함하도록 Next.js 앱을 구성할 수 있습니다. 

이렇게 하려면 아래와 같이 next.config.js 파일의 pageExtensions 항목을 수정하면 됩니다. 그런 다음 .page(_document.page.js, _app.page.js, index.page.js )를 포함하는 파일 확장자를 갖도록 페이지 구성 요소의 이름을 바꿉니다.

 module.exports = {

    pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js']

}

이 구성을 사용하면 Next.js는 페이지/API 경로 및 라우팅을 구축하기 위해 .page를 포함하지 않는 모든 파일을 무시합니다.

 

 

 

이거보고 next.config.js에서 페이지별 설정 넣어야한다는 공식문서보고 혹시 넣어봤는데 build되네 호..

잘 모르겠음 그리고 빌드를 하면 out에 서버페이지가 생기는 거 맞나? 

dev는 개발모드고

정확한 차이를 정리해봐야겠다.

 

 

 

 

이 공식문서 봄

https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory

 

 

 

next.config.js

파일에 이거 추가함

module.exports = {
  pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js'],
}

 

 

다시 원위치..

 

 

문제는 이거를 넣으면 

기존 경로

local:3000 이 404로 페이지를 찾을 수 없다고 뜨고 안열린다. 

 

원래대로 지워줘야 뜨네 흠.. 

 

아 문서를 읽어보니 

pageExtensions를 넣고 나서 

이름을 바꿔줘야되는구나 

 

이름 바꿔줌

 

 

해결됨

 

라고 생각했는데 안떠서 다시..

 

https://stackoverflow.com/questions/65598753/cant-build-react-next-project-found-page-without-a-react-component-as-default

 

 

 

Can't build React/Next project - found page without a React Component as default export (context api file)

I'm trying to build my Next.js project but it keeps giving me this error in the terminal: Error: Build optimization failed: found page without a React Component as default export in pages/components/

stackoverflow.com

 

728x90
728x90

https://webisfree.com/2020-02-17/[%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8]-%EA%B0%9D%EC%B2%B4%EB%A5%BC-%EC%83%88%EB%A1%9C%EC%9A%B4-%EA%B0%9D%EC%B2%B4%EB%A1%9C-%EB%B3%B5%EC%82%AC-clone%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95 

 

[자바스크립트] 객체를 새로운 객체로 복사 clone하는 방법

자바스크립트에서 객체를 복사, 복제(Clone)하는 방법에 대하여 알아봅니다.

webisfree.com

https://jung-story.tistory.com/118

 

DB (Master & Slave 개념 및 구조)

개요 소프트웨어를 개발하는데 가장중요한것은 DB를 설계하는 것이라고 생각합니다. 많은 소스를 보면서 DB구조가 Master & Slave로 되어있는것 을 볼 수 있었는데, 자세한 개념을 알아 보도록 하겠

jung-story.tistory.com

 

 

https://myinfrabox.tistory.com/20

 

[MySQL][Admin] Binary 로그 소개 및 특징

■ MySQL 바이너리 로그 ▶ 바이너리 로그란?? MySQL 서버에서 Create, Drop, Alter같은 DDL과 Insert, Update, Delete같은 DML을 통해 데이터베이스, 오브젝트, 데이터에 생성,수정,업데이트를 했을 시 그 변화된.

myinfrabox.tistory.com

 

parseInt("-10"); // -10

문자열 "-10"을 숫자로 변환하여 정수 음수 -10을 리턴합니다.

 

parseInt("10.9"); // 10

문자열 타입의 실수값은 소수점을 제거한 후, 정수값만 리턴합니다.

출처: https://hianna.tistory.com/386 [어제 오늘 내일:티스토리]

 

 

 

Array.prototype.slice()

시도해보기

slice() 메서드는 어떤 배열의 begin부터 end까지(end 미포함)에 대한 얕은 복사본을 새로운 배열 객체로 반환합니다. 원본 배열은 바뀌지 않습니다.

const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];

console.log(animals.slice(2));
// expected output: Array ["camel", "duck", "elephant"]

console.log(animals.slice(2, 4));
// expected output: Array ["camel", "duck"]

console.log(animals.slice(1, 5));
// expected output: Array ["bison", "camel", "duck", "elephant"]

console.log(animals.slice(-2));
// expected output: Array ["duck", "elephant"]

console.log(animals.slice(2, -1));
// expected output: Array ["camel", "duck"]

console.log(animals.slice());
// expected output: Array ["ant", "bison", "camel", "duck", "elephant"]

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/slice

 

728x90
728x90

https://kyun2da.dev/react/%EB%A6%AC%EC%95%A1%ED%8A%B8-%EB%9D%BC%EC%9D%B4%ED%94%84%EC%82%AC%EC%9D%B4%ED%81%B4%EC%9D%98-%EC%9D%B4%ED%95%B4/

 

리액트 라이프사이클의 이해

시작하기 전에 리액트 라이프 사이클을 원래 알고는 있었지만 정확하게 한번도 정리해본 적이 없는 것 같아서 글을 쓰게 되었다. 더불어 리액트 라이프 사이클과 최근 사용되는 Hooks와도 비교해

kyun2da.dev

 

728x90
728x90

https://d2.naver.com/helloworld/59361

 

 

 

스타일 설명까지 읽었는데 

솔직히 다 이해가 가지는 않는다 다시 읽어봐야지...

728x90
728x90

 1. 브라우저 렌더링 과정

 

엔진마다 렌더링 조금씩 다름, 크롬 기준으로 볼거임

 

(브라우저의 주요 기능은 사용자가 선택한 자원(보통 html) 서버에 요청하고 브라우저에 표시하는 )

* DOM document object model 약자이며, 한글로는 "문서 객체 모델"이라고 부릅니다DOM 객체 지향 모델로써 구조화된 문서를 표현하는 방식

문서 파싱은 브라우저가 코드를 이해하고 사용할 있는 구조로 변환하는 것을 의미

 

태그가 노드객체로 변환되고

연관성 갖을 있도록 트리를 생성함 이게 바로 DOM트리임

최상위에는 document객체가 들어감

 

DOM tree 생성되고, CSS CSSOM tree생성됨

그리고 렌더링 엔진이 DOM트리와 CSSOM 트리 합쳐서 render tree렌더트리 생성

렌더트리는 화면에 표시될 모든 정보 포함하는 트리임

렌더트리가 생성된다음 layout이라는 과정 거침 (reflow라고도 )

뷰포트에 맞춰서 요소들의 정확한 위치랑 크기를 계산하는 과정임

계산하고 화면에 실제 픽셀로 변환해서 그리는 페인트 과정함

출처:  [10분 테코톡] ☕️ 체프의 브라우저 렌더링 https://www.youtube.com/watch?v=sJ14cWjrNis

 

 

사용자가 정보 업데이트 했을때는?

3가지 경우로 동작함

1. 레이아웃이 다시 발생하는 경우 크기 위치

2. 페인트부터 다시 발생되는 경우 -텍스트 이미지

3. 레어어의 합성만 다시 발생

 

2. virtual dom

 

 

 

 

출처:[10분 테코톡] 🥁 지그의 Virtual DOM https://www.youtube.com/watch?v=PN_WmsgbQCo&t=20s

문제는

변화가 발생할때마다 렌더트리가 다시 생성된다는 것이다.

이 과정을 다시 반복하게 됨.

게다가 최근에는 SPA, single page application(페이지를 변경하지 않고 동일한 페이지에서 조작

페이지를 서버가 아닌 브라우저에서 관리)을 많이 사용하면서 dom tree를 변경할 일이 많아졌음

 그래서 virtual dom이 등장했다.

출처:[10분 테코톡] 🥁 지그의 Virtual DOM https://www.youtube.com/watch?v=PN_WmsgbQCo&t=20s

가상돔에 생긴 변경사항을 반영해서 전체 real dom을 바꾸지 않아도 됨

 

이런 처린 실제 돔 아닌 메모리상에서 동작해서 훨씬 빠름

가상돔은 실제로 렌더링 되지 않아서 연산비용을 최소화할 수 있다. 

 

 

virtual dom이 하는 것은 

DOM fragment의 변화를 묶어서 적용한 다음

기존 DOM에 던져주는 과정을 자동화, 추상화해놓은 것이다. 

 

리액트가 가상돔을 이용하는 자바스크립트 라이브러리다. 

ui의 가상적인 표현을 메모리에 저장하고 reactDOM과 같은 라이브러리에 의해 

실제돔과 동기화하는 프로그램이다.

리액트는 JSX를 사용하는데, 각 컴포넌트에서 리턴되는 react element를 JSX문법으로 작성하는 것이다.

JSX는 자바스크립트 확장 문법이다.

바벨이 JSX를 React.createElement()호출로 컴파일한다. 컴파일하는 걸 보면 React elemet객체를 리턴하는 것을 볼 수 있다. 

React elements는 DOM요소의 가상 버전으로 가볍고 상태가지지 않고 불변성 유지한다. 

render에 의해서 실제 돔에 반영한다

 

 

 

 

 

 

https://www.youtube.com/watch?v=PN_WmsgbQCo&t=20s 

 

728x90
728x90

 https://velog.io/@joosing/10-things-to-remember-when-testing

 

(주니어 개발자에게 전하는) 테스트할 때 기억할 10가지

그는 내 말을 무시했거나, 불성실 했던 것이 아니고 잘 몰라서 그랬던 거였습니다. 그래서 내가 잘못 가정했던 당연한 것들을 가르쳐 줘야 겠다고 생각했습니다.

velog.io

간단 요약

 

테스트는 

1. 기대되는 결과

2. 실제로 시스템이 내뱉은 결과. 

이 두 가지 요소를 갖고 있음

기대되는 결과와 실제 결과가 다르면 실패한 것이다. 

그대 반대로 시스템에게 맞지 않는 과한 테스트를 하는 실수를 할 수도 있다.

 

제품의 요구사항을 잘 파악하고 테스트를 해야한다.

제품의 요구사항은 사실 제품이 만들어지기 전에 테스트하면서 개선하면서 생김

사용자 관점으로 보아야한다. 

또한 우리가 사용하는 기술에 대해 이해해야 올바른 테스트를 할 수 있다

상호작용하는 인터페이스 동작하는지 확인

모든 메뉴 클릭해보고 예상한 결과가 출력되는지 확인

사용시 시스템의 일관성이 유지되는지 확인할 것

섬세함

적극적 태도가지고 문제 해결해라

728x90
728x90

리액트 네이티브란?

페이스북에서 만든 오픈소스 모바일 애플리케이션 프레임워크이다.

 

HTML,CSS 대신 자바스크립트 스레드로 이뤄져 있다.

 

장점

 JavaScript를 사용하여 Android 와 iOS를  동시에 개발할 수 있어 효율적이다.

codePush를 통한 배포로 원하는 기능을 스토어를 거치지 않고 할 수 있다.

쉽고 빠른 UI 작성을 할 수 있다.

리액트 개발자가 사용하기 쉽다.

단점

성능이슈가 쉽게 나타나 낭비되는 렌더링을 확인해야 한다.

버그의 원인을 추적해나가는 과정이 다소 어렵다.

빌드타임이 오래 걸린다.

 

Windows, Linux 또는 Mac OS를 사용하여 React Native를 시작할 수 있습니다.

iOS 및 Android 환경은 Mac OS에서 모두 사용 가능하지만

Linux와 Windows는 Android 환경만 지원합니다.

React Native 개발을 위해 macOS를 사용한다고 하지만 Windows 및 Linux에서도

할 수 있다.

 

 

React Native 를 시작하는 두 가지 방법이 있다.

 

Expo CLI  

설치 및 배포가 쉬움 하지만 expo 라이브러리를 써야돼서 한정적일 수 있음

 

React Native CLI

설치해야되는 것들이 상대적으로 많음

 

 

 

 

expo란?

“create-react-native-app was replaced by expo-cli.”

Expo CLI는 개발자와 Expo 도구 간의 기본 인터페이스인 명령줄 앱입니다.

쉬운 앱개발을 할 수 있습니다.

Expo 는 ios, Android앱 개발할 수 있는 프레임워크이자 플랫폼이다

https://docs.expo.dev/workflow/expo-cli/

 

Expo CLI - Expo Documentation

Expo is an open-source platform for making universal native apps for Android, iOS, and the web with JavaScript and React.

docs.expo.dev

 

 

 

 

expo 설치 (with 타입스크립트)

 

Nodejs 가 설치되어있어야 한다.

 

npm install -g expo-cli

 

expo init 폴더명

cd 폴더명


npm start # you can also use: expo start

 

 

(expo 앱 깔아서 QR찍어서

핸드폰으로 연동해서 보면 되는데 

만약에 

android emulator로 보고 싶으면

 

Run on Android device/emulator 를 클릭하면, 자동으로 연결된다.

 

또는 터미널 상에서 a 버튼을 누르면 바로 실행된다.

Press a for Android emulator, or w to run on web.)

 

 

 

기존 프로젝트에 typescript 추가하기

npm install -D typescript @types/jest @types/react @types/react-native @types/react-test-renderer

 

참고 :

https://reactnative.dev/docs/typescript#adding-typescript-to-an-existing-project

 

Using TypeScript · React Native

TypeScript is a language which extends JavaScript by adding type definitions, much like Flow. While React Native is built in Flow, it supports both TypeScript and Flow by default.

reactnative.dev

 

 

TypeScript 구성 파일을 추가합니다. tsconfig.json프로젝트의 루트에 생성

{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-native",
"lib": ["es2017"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js"
]
}

jest.config.jsTypeScript 사용하도록 Jest를 구성 하는 파일 만들기

module.exports = {
preset: 'react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};

JavaScript 파일의 이름을 다음과 같이 변경하십시오.*.tsx

./index.js은 그대로 두어야 한다. 그렇지 않으면 프로덕션 빌드 번들링과 관련하여 문제가 발생할 수 있습니다.

 

yarn tsc

새 TypeScript 파일을 유형 검사하려면 실행하십시오 .

(만약 안된다면  npm install typescript –g 로 전역설치

https://stackoverflow.com/questions/39404922/tsc-command-not-found-in-compiling-typescript)

 

'tsc command not found' in compiling typescript

I want to install typescript, so I used the following command: npm install -g typescript and test tsc --version, but it just show 'tsc command not found'. I have tried many ways as suggested in

stackoverflow.com

 

 

 

 

 

 

 

 

 

react native cli 설치

 

 

1.자바 설치 (JDK)  Java Downloads | Oracle

- “고급 시스템 설정”에서 환경변수 수정 (시스템속성->환경변수 -> 새로 만들기)

변수 이름 적고, 하단에는 설치한 폴더 경로 입력 후 확인.

-시스템 변수에서 path 클릭, 새로 만들기 클릭, %JAVA_HOME%\bin 입력후 확인

-명령 프롬프트 에

 

javac    (javac 명령오는 텍스트 파일로 작성된 java 파일을 bytecode로 컴파일함)

java-version 입력해 버전 값 나오는지 확인

 

 

 

 

2. 안드로이드 스튜디오 설치 및 환경설정 Download Android Studio and SDK tools  |  Android Developers

-Tools에서 SDK manager 들어가서 사용할 디바이스 선택 및 설치

-환경변수 수정

 

 

 

3. Nodejs 설치 Node.js (nodejs.org)

4. Python 설치 Download Python | Python.org

5. npx react-native init AwesomeProject  

(타입스크립트 템플릿 추가

npx react-native init AwesomeTSProject --template react-native-template-typescript

)

6. npx react-native start

7. npx react-native run-android (새 터미널 창에서 입력, npm run android 해도 됨)

 

 

참고(특히 환경변수 설정 참고~~!) : https://marshmello.tistory.com/69

 

React Native 설치 및 프로젝트 생성하기

저번글에서는 리액트 네이티브가 무엇인지 작성하였습니다. https://marshmello.tistory.com/68?category=1213283 이번글에서는 리액트 네이티브로 프로젝트를 생성해 보도록 하겠습니다. 1. 자바 설치 및 환

marshmello.tistory.com

https://reactnative.dev/docs/environment-setup

 

에러났을 때

-에러 SDK tool 안 깔려 있는 것이 없는지 확인

-경로 확인(환경변수 확인)

 

에러 

error failed to launch emulator. Reason:No emulators found as an output of `emulator -list-avds` 

 

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file

해결

local.properties 파일 만들어서 해결

(sdk.dir=해당 경로 입력)

참고: https://healthcoding.tistory.com/35

https://eso0609.tistory.com/92 

https://stackoverflow.com/questions/59355688/how-to-solve-the-error-failed-to-launch-emulator-reason-no-emulators-found-as

 

How to solve the error, Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds` in React nat

I am creating react native app for mobile application. I am fully new in building react native app. I am using ubuntu for creating the app and following below link to create the app. https://facebook.

stackoverflow.com

 

 

 

728x90
728x90

https://ridicorp.com/story/react-native-1year-review/

 

리액트 네이티브 앱 전환 그리고 1년 후 - 리디주식회사 RIDI Corporation

2020년 2월, 애니메이션 스트리밍 서비스 라프텔에서는 기존에 Android 와 iOS 각각 따로 구현되어 있던 애플리케이션을 리액트 네이티브 를 통해 개발을 통합하여 할 수 있도록 리빌드를 했습니다.

ridicorp.com

 

라프텔에서

네이티브에서 리액트로 앱전환하면서 겪은 여러 시행착오와 고민들

 

지금 리액트 네이티브 공부 중이라 아주 흥미롭다.

 

728x90
728x90

귯귯

 

자동생성 1초씩으로 해봄

 

 

 

이 데이터베이스 사용할거임

use testscedule;

 

이벤트스케줄러 켜져있는지 확인

 

show variables like 'event%';

on으로 켜져있음

 

만약off면 

 SET GLOBAL event_scheduler = ON;

로 활성화

 

(만약 시작될때마다 초기화로 꺼지면 요방법)

https://web-inf.tistory.com/17 

https://bizadmin.tistory.com/entry/mysql-%EC%9D%B4%EB%B2%A4%ED%8A%B8-%EC%8A%A4%EC%BC%80%EC%A5%B4%EB%9F%AC-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0

 

 



CREATE EVENT if not exists forme  //forme라는 이벤트 없으면 만듦
ON SCHEDULE EVERY 1 second //1초마다 실행
STARTS CURRENT_TIMESTAMP //지금시간부터 시작~
DO
INSERT INTO new_table (name) values ('hi');  //실행할 쿼리문~

 

 

 


SHOW EVENTS ; //이벤트 확인

 

이벤트 삭제

DROP EVENT IF EXISTs forme;

 

 

사실 해도 실행이 안됐었다. 

알고보니 insert에서 막히는 것이었음

만든 table 에서 id가 not null로 빈값 못들어가는데 name만 자꾸 넣어주려니까 안되었던 것이다.

id를 Auto Incremental로 자동 순번 지정되게 수정해주니 

name이 잘 들어갔다. id도 자동으로 들어가고

 

 

*schedule

오타^^+

 

 

 

 

 

https://soccerda.tistory.com/entry/MySQL-Scheduled-Event

 

MySQL Scheduled Event

오라클의 job과 유사한 기능을 지원하는 Mysql DB에는 scheduled Event기능이 있습니다. MySQL 이벤트 스케줄러 및 데이터베이스 작업을 자동화하는 방법에 대해서 기술하겠습니다. MySQL 이벤트는 미리

soccerda.tistory.com

 

728x90
728x90

공식문서 참조함. 

git 메뉴얼_이소윤 사원.pdf
2.34MB

 

728x90
728x90

 

SSH란 Secure SHell의 약자로 네트워크 상의 다른 컴퓨터에 로그인하거나 원격으로 명령을 실행할 수 있는 프로그램 또는 프로토콜을 의미한다. 포트번호는 22번을 사용한다. 이러한 SSH를 이용해 서버에 접속하여 명령어를 전송하는 원격 서버 접속 프로그램 PuTTY 이다. 사실 PuTTY 는 SSH 뿐만 아니라 Telnet, Rlogin 등 다양한 방법을 제공하고 있지만, Talnet 은 보안상의 문제로 잘 사용하지 않고, 보통 SSH 를 이용하여 원격 서버에 접속하기 위해 사용한다.

https://salix97.tistory.com/280

 

[PuTTY] 푸티를 사용하여 원격 리눅스 서버에 접속하기

과제를 학교 실습 서버(리눅스)에 접속하여 제출해야 한다. 학교 실습 서버는 나와 물리적으로 떨어져 있다. 이런 서버를 원격 서버라고 한다. PuTTY 는 이러한 원격 서버에 접속하기 위해 사용하

salix97.tistory.com

보통 서버는 IDC센터에 별도로 관리되고 있기 때문에 서버에 무언가 작업을 위해 매번 IDC센터에 방문하여 출입 허가 받고, 서버에 직접 접속하는 것이 여간 번거로운 일이 아닙니다.

이러한 서버에 회사에서 또는 집에서 원격으로 접속하여 작업을 할 수 있다면 상당히 편하겠죠. PuTTY는 Telnet 또는 SSH 등의 원격 접속을 통해 서버에 직접 접근하여 작업을 수행할 수 있습니다.

 

Telnet 과 SSH 는 원격 접속을 위한 프로토콜인데, 차이점은 Telnet은 패킷 암호화 기능이 없고, SSH는 있다는 점입니다. SSH는 서버에게 보내는 패킷을 암호화하기 때문에 중간에 패킷을 가로채기 당하더라도 패킷 복호화를 위한 키를 가지고 있지 않기 때문에 내용 확인이 불가능합니다.



출처: https://ooz.co.kr/89[이러쿵저러쿵]

 

PuTTY 프로그램 (Telnet, SSH 서버 원격 접속)

PuTTY는 리눅스나 유닉스 계열의 서버 관리자라면 다들 써보았을 프로그램으로 서버에 원격 접속을 하기 위해 사용하는 프로그램입니다. (푸티 또는 퍼티라고 말하더군요.^^) 보통 서버는 IDC센터

ooz.co.kr

PuTTY는 SSH(Secure Shell), Telnet, TCP 접속을 위한 클라이언트입니다.

일반적으로 Window환경의 호스트 운영체제에서 다른 운영체제에 CLI(Command Line Interface)환경의 SSH 접속에 편리하며 또한 설치와 사용법이 굉장히 간단하다는 장점도 있습니다.

 

 

 

 

 

https://antdev.tistory.com/44

 

PuTTY란 ? PuTTY 설치하기

PuTTY란 ? PuTTY는 SSH(Secure Shell), Telnet, TCP 접속을 위한 클라이언트입니다. 일반적으로 Window환경의 호스트 운영체제에서 다른 운영체제에 CLI(Command Line Interface)환경의 SSH 접속에 편리하며 또한..

antdev.tistory.com

 

 

 

 

https://www.putty.org/

 

Download PuTTY - a free SSH and telnet client for Windows

Is Bitvise affiliated with PuTTY? Bitvise is not affiliated with PuTTY. We develop our SSH Server for Windows, which is compatible with PuTTY. Many PuTTY users are therefore our users as well. From time to time, they need to find the PuTTY download link. W

www.putty.org

 

728x90
728x90

조건

 

피보나치 수열

1 1 2 3 5 8 13 ...

 

이렇게 

1분 1분 2분 3분 

지날 때마다

-2%로 이자액이 원금에서 차감되게 식 만들기 

 

 

 

 

검색통해서 피보나치 구하는 식은 썼는데 

 

시간 흐를 때마다 추가되게끔은 못함..

drop database testDB;
create database testDB;

use testDB;
create table testDB(
id INT(11)  NOT NULL AUTO_INCREMENT,                
  name VARCHAR(45) ,                        
 deposit_date DATETIME,                      
deposit_amount INT,                                   
interest_amount INT,
 CONSTRAINT testTable_PK PRIMARY KEY(id)                     
);

set @setTime = (select subtime(now(),'00:02:00'));

insert into testdb (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,10000000,0);

drop function if exists fibo_number;
DELIMITER //
CREATE FUNCTION fibo_number(n INT) RETURNS INT
DETERMINISTIC
BEGIN
	
    DECLARE f_0 INT default 0;
    DECLARE f_1 INT default 1;
    DECLARE out_fib INT;
    DECLARE i INT;
    DECLARE f_2 INT;

    SET f_0 = 0;
    SET f_1 = 1;
    SET i = 1;

    
    WHILE (i<=n) DO
   
        SET f_2 = f_0 + f_1;
        SET f_0 = f_1;
        SET f_1 = f_2;              
       SET i = i + 1;  
       SET out_fib = f_0;          
	
    END WHILE;
    	  RETURN out_fib;


END //

set @n =  (select fibo_number(6))//
select @n//

drop procedure if exists pro//
create procedure pro()
begin

while (select id from testdb order by id desc limit 1) < 10 do
INSERT INTO testdb (name,deposit_date,deposit_amount,interest_amount) 
select 
(select  MIN(name) from testdb),
date_add((select MAX(deposit_date) from testdb),INTERVAL @n minute),
((select MIN(deposit_amount) from testdb ) - (select MAX(interest_amount) from testdb)),
(select deposit_amount from testdb where id =1)* 0.02;
end while;
end //
delimiter ;

call pro();

select * from testdb;

 

https://shoark7.github.io/programming/algorithm/%ED%94%BC%EB%B3%B4%EB%82%98%EC%B9%98-%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98%EC%9D%84-%ED%95%B4%EA%B2%B0%ED%95%98%EB%8A%94-5%EA%B0%80%EC%A7%80-%EB%B0%A9%EB%B2%95.html

 

피보나치 수열 알고리즘을 해결하는 5가지 방법

Let me introduce 5 different ways to solve fibonacci algorithm

shoark7.github.io

https://hongjw1938.tistory.com/47

 

알고리즘 - Dynamic Programming(동적 계획법)

1. 개요 DP, 즉 다이나믹 프로그래밍(또는 동적 계획법)은 기본적인 아이디어로 하나의 큰 문제를 여러 개의 작은 문제로 나누어서 그 결과를 저장하여 다시 큰 문제를 해결할 때 사용하는 것으

hongjw1938.tistory.com

https://stackoverflow.com/questions/69821788/create-and-call-mysql-function-to-find-fibonacci-numbers-till-n-numbers

 

Create and call MYSQL Function to find Fibonacci numbers till n numbers

My approach DELIMITER $$ CREATE FUNCTION fibonacci(num INT) RETURNS INT DETERMINISTIC BEGIN DECLARE fib1 INT DEFAULT 0; DECLARE fib2 INT DEFAULT 1; DECLARE fib3 INT DEFAULT 0; DECLA...

stackoverflow.com

 

728x90
728x90

 

https://stepby-yun.tistory.com/193

 

한시간씩 이자율 넣기 while문 사용, update,order by limit

https://stepby-yun.tistory.com/192?category=554522 mysql while 여러시도.. https://stepby-yun.tistory.com/191 mysql procedure 프로시저 생성 및 실행 (구본문자 DELIMITER ) while문 해보려는데.. 나와같은..

stepby-yun.tistory.com

 

max 랑 min써서 잘들어가긴했는데

order했을때 왜 null떴나 싶어서 

다시 해봄

 

 

 

 

 

 

where 조건문을 잘못넣었네

 

 

 

 

 

 

where interest_amount 

빼니까 잘 들어감

 

 

 

 

없네

근데

다른애들은 where 있고 없고 결과값 똑같은데 뭐지

일단 확실한건 

where 조건문

인데 조건문아니고 테이블만 써서 잘못되긴함. 

 

<수정결과>

use test;
truncate sequence;


set @setTime = (select subtime(now(),'00:02:00'));

insert into sequence (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,10000000,0);

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while (select id from sequence order by id desc limit 1) < 10 do


INSERT INTO sequence (name,deposit_date,deposit_amount,interest_amount) 
select 
(select name from sequence order by id desc limit 1),
date_add((select deposit_date from sequence  order by id desc limit 1),INTERVAL 1 hour),
((select deposit_amount from sequence order by id desc limit 1) + (select interest_amount from sequence  order by id desc limit 1)),
(select deposit_amount from sequence where id=1)* 0.04 /12;


end while;
end //
delimiter ;

call pro();




select * from sequence;

 

 

 

 

+

참고로 empty set이 무어냐

쿼리 수행 결과가 없다는 뜻

 

 

https://www.tutorialspoint.com/What-is-the-meaning-of-empty-set-in-MySQL-result-set

테이블 조건만으로는 그 값을 찾을 수 없었나봐...

 

728x90
728x90

https://stepby-yun.tistory.com/194

 

MAX MIN order by limit 차이 뭘 쓸지

https://stepby-yun.tistory.com/193 한시간씩 이자율 넣기 while문 사용, update,order by limit https://stepby-yun.tistory.com/192?category=554522 mysql while 여러시도.. https://stepby-yun.tistory.com/1..

stepby-yun.tistory.com

지난 시간

max나 min쓰자~

 

 

 

이번에는 줄어드는 계산식

 

이전코드에서 
빼면 되겠거니~~했는데!

오잉

 

아 이전에는 deposit_amount가 점점 커져서 

MIN 최소값에 이자율곱해서 이자액 구했는데

이제는 줄어들어서 최대값 사용해서 이자금액 구해야하는구나

 

MAX로 바꿈

음...

아 최대값에서 빼주니까 안줄어드는구나

 

최소값(마지막행)에서 빼주기로 변경

 

 

 

굿굿~

 

이자율만 수정하면 끝

 

 

use test;
truncate sequence;


set @setTime = (select subtime(now(),'00:02:00'));

insert into sequence (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,10000000,0);

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while (select MAX(id) from sequence) < 10 do


INSERT INTO sequence (name,deposit_date,deposit_amount,interest_amount) 
select 
(select MIN(name) from sequence),
date_add((select MAX(deposit_date) from sequence),INTERVAL 1 hour),
((select MIN(deposit_amount) from sequence) - (select MAX(interest_amount) from sequence)),
(select MAX(deposit_amount) from sequence)* 0.02;


end while;
end //
delimiter ;

call pro();


select * from sequence;

 

 

 

 

 

 

이거는 order by 랑 섞어서 쓴거. 

use test;
truncate sequence;


set @setTime = (select subtime(now(),'00:02:00'));

insert into sequence (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,10000000,0);

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while (select MAX(id) from sequence) < 10 do

INSERT INTO sequence (name,deposit_date,deposit_amount,interest_amount) 
select 
(select MIN(name) from sequence),
date_add((select MAX(deposit_date) from sequence),INTERVAL 1 hour),
((select deposit_amount from sequence where  deposit_amount order by id desc limit 1) - (select MAX(interest_amount) from sequence)),
(select deposit_amount from sequence where id =1)* 0.02;

end while;
end //
delimiter ;

call pro();

select * from sequence;

똑같음

 

 

 

 

 

이제 예산이 0 될때까지 해볼게

 

 

끝~

 

 

+

 

참고로 >= 0로 해봤는데

0보다 크거나 같다고 하니까 에러뜸

 

 

이거보니 타입이 unsigned로 되어있는데 

음수값이 나오려고 해서 에러뜨는거라함

 

아하 deposit_amount가 0일때 while문을 돌리면

interest_amount 값을 0에서빼게 되니까

음수값이 들어가게 되는구나

 

https://wwwnghks.tistory.com/122

 

[Mysql] SQL 오류 (1690): BIGINT UNSIGNED value is out of range in 에러 발생시

SQL 오류 (1690): BIGINT UNSIGNED value is out of range in.... 위의 에러 발생 이유는 아래와 같이 컬럼명의 타입이 unsigned 로 되어있고, 음수의 값이 발생되는 경우 발생된다. select (컬럼명 - 100) from..

wwwnghks.tistory.com

 

728x90
728x90

https://stepby-yun.tistory.com/193

 

한시간씩 이자율 넣기 while문 사용, update,order by limit

https://stepby-yun.tistory.com/192?category=554522 mysql while 여러시도.. https://stepby-yun.tistory.com/191 mysql procedure 프로시저 생성 및 실행 (구본문자 DELIMITER ) while문 해보려는데.. 나와같은..

stepby-yun.tistory.com

지난시간~

 

 

select deposit_amount where  deposit_amount order by id desc limit 1

이 order by id dec limit 1

을 사용해서 마지막행 값을 구했었다. 

 

 

우와 max로 썼더니 

null값 사라짐!

 

확실한 건 코드가 짧아져서 너무 좋음ㅋㅋㅋㅋ

구하려는 열과 테이블만 적으면 됨

 

 

 

use test;
truncate sequence;


set @setTime = (select subtime(now(),'00:02:00'));

insert into sequence (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,10000000,0);

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while (select MAX(id) from sequence) < 10 do


INSERT INTO sequence (name,deposit_date,deposit_amount,interest_amount) 
select 
(select MIN(name) from sequence),
date_add((select MAX(deposit_date) from sequence),INTERVAL 1 hour),
((select MAX(deposit_amount) from sequence) + (select MAX(interest_amount) from sequence)),
(select MIN(deposit_amount) from sequence)* 0.04 /12;


end while;
end //
delimiter ;

call pro();



select * from sequence;

 

 

 

근데 둘의 차이가 뭘까? 뭘쓰는게 좋을까

 

 

단순히 테이블에서 최대값, 최소값을 찾고 싶다면

MAX() MIN() 함수 활용하는게 간단하다

 

최대값 또는 최소값을 갖는 row 열을 찾는 경우,

order by limit 1 을 사용한다.

 

 

 

 

성능으로 봤을 때 min을 쓰는게 좋다

 

 

min은 바로 최솟값을 가져오지만

order by limit1은 실행할 때마다 정렬을 한다. 

 

최악의 경우, 인덱스가 없는경우

min 이 order by limit 1 보다 빠르다

최선의 경우, 인덱스가 있는경우

min 과 order by limit 1 의 성능을 비슷하다

하지만 그래도 order by limit1은 실행할 때마다 정렬을 한다. 

 

 

 

 

 

최대값

select MAX(컬럼) from 테이블;

최소값

select MIN(컬럼) from 테이블;

 

 

 

ORDER BY

정렬할 때 사용

 

asc:오름차순 (안써도 된다)
desc:내림차순

 

limit 가져오는 레코드의 개수를 제한한다

 

 

 

 

 

 

 

https://eyeballs.tistory.com/463

 

[SQL] Min 과 Order By limit 1 중 어느 것을 사용해야 할까?

min 과 order by limit 1 중 어느 것이 더 나은 성능을 보일까? 그래서 어느 것을 사용해야 할까? < 결과 > min 값만 구하는 경우 min 을 사용 min 값을 갖는 row 를 찾아야 하는 경우 order by limit 1 을 사용 <..

eyeballs.tistory.com

https://stackoverflow.com/a/426785

 

MIN/MAX vs ORDER BY and LIMIT

Out of the following queries, which method would you consider the better one? What are your reasons (code efficiency, better maintainability, less WTFery)... SELECT MIN(`field`) FROM `tbl`; SELECT `

stackoverflow.com

https://www.inflearn.com/questions/23797

 

max/min vs. order by + limit 질문 - 인프런 | 질문 & 답변

안녕하세요, 최대값과 최소값 찾는 방법에 대해 질문드려요. 가장 쉬운 방법으로는 MAX() 와 MIN()를 쓰는 방법이 있는데, 수업 중에 선생님께서 order by ___ desc, limit 1 와 order by ___ asc, limit 1도 가르

www.inflearn.com

 

https://sql-factory.tistory.com/634

 

 

 

 

MySQL MIN / MAX 대 ORDER BY 및 LIMIT

다음 쿼리 중 더 나은 방법을 고려할 수있는 방법은 무엇입니까? 당신의 이유는 무엇입니까 (코드 효율성, 더 나은 유지 보수성, 덜 WTFery) ... SELECT MIN(`field`) FROM `tbl`; SELECT `field` FROM `tbl` ORDE..

sql-factory.tistory.com

https://pram.tistory.com/entry/%EC%9E%90%EB%A3%8C%EA%BA%BC%EB%82%B4%EA%B8%B0select-ORDER-BY-LIMIT

 

728x90
728x90

https://stepby-yun.tistory.com/192?category=554522 

 

mysql while 여러시도..

https://stepby-yun.tistory.com/191 mysql procedure 프로시저 생성 및 실행 (구본문자 DELIMITER ) while문 해보려는데.. 나와같은 의문을 가지신 분 프로시저 꼭 만들어서 써야돼? https://stackoverflow.com/q..

stepby-yun.tistory.com

프리비어슬리~

 

새로 생긴 행이랑 이전 행 시간을 빼서 1분 이상일때마다

값을 넣어줄까? 했는데 무한insert되고 난리남

 

(이 글의 결론)

1분이 흐를때마다 ->이자증액값을 넣어준다

에서

값넣는다. 1분마다시간증가, 이자증액, 

이렇게

insert할때 한꺼번에 넣는 걸로 식만듦..(저번에 한달씩 증가랑 똑같이 함.)

------

 

 

 

기준 잡기의 중요성..

한 시간씩 증가하고

넣고 먼저 해보자

최대증가한 시간

몇번째 행의 시간이 얼만지 생각! 

 


 

use test;
truncate sequence;


set @setTime = (select subtime(now(),'00:02:00'));

insert into sequence (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,'10000000','0');

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while (select id from sequence order by id desc limit 1) < 10 do


INSERT INTO sequence (name,deposit_date,deposit_amount,interest_amount) 
select 
(select name from sequence order by id desc limit 1),
date_add((select deposit_date from sequence where  deposit_date order by id desc limit 1),INTERVAL 1 hour),
((select deposit_amount from sequence where  deposit_amount order by id desc limit 1) + (select interest_amount from sequence where  interest_amount order by id desc limit 1)),
(select deposit_amount from sequence where id='1')* 0.04 /12;

end while;
end //
delimiter ;

call pro();

select * from sequence;
 


아 다음행에 insert 추가 되는게

마지막 id가 9이니까

 

10까지 뜨는거구나~!!

 

그래도 deposit_amount의 마지막행 10000000을 구해서 이자액 33333을 구했으면 

 

2번째 행에 deposit_amount도 들어갈 수 있는거 아닌가 왜 

 

null값이지? 

 

 

+

 

지금은 한번에 들어가는거니까 

날짜를 추가하고 추가될때마다 이자액이 찍히게 하면 되려나...

 

 

update써서 해보자

 

update 안되는이유 여기서 세팅 설정바꿔줘야함

https://lightblog.tistory.com/193

 

[MYSQL] 에러 번호 1175 Safe Update 해결방법

MySQL에서 쿼리를 실행하다보면 다음과 같은 에러를 마주할 때가 있다. Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable..

lightblog.tistory.com

오마갓 숫자를 ''

여기 넣어서 문자열로 만들어서 쓰고있었네

 

 

 

 

하지만 잘 안됨

use test;
truncate sequence;
set @setTime = (select subtime(now(),'00:02:00'));
insert into sequence (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,10000000,0);





drop procedure if exists pro;
delimiter //
create procedure pro()
begin
DECLARE n varchar(45) default "이소윤" ;

while (select id from sequence order by id desc limit 1) < 10 do
INSERT INTO sequence (deposit_date) select (date_add((select deposit_date from sequence where  deposit_date order by id desc limit 1),INTERVAL 1 hour));

update sequence 
set 
name = n,
interest_amount =  (select deposit_amount where  deposit_amount order by id desc limit 1)* 0.04 /12;




end while;

end //
delimiter ;
call pro();

select * from test.sequence;


 

---

시간 증가만 insert해주고

나머지는 update로 넣어주려 했으나 잘안됨..

그래서 원래 한번에 다 insert한 걸로 수정함

 

중간에 null인거..

 

 

그냥 id가 2인거 조건으로 넣어줌..

이러면 안될거같지만

use test;
truncate sequence;


set @setTime = (select subtime(now(),'00:02:00'));

insert into sequence (name,deposit_date,deposit_amount,interest_amount) values ('이소윤',@setTime,10000000,0);

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while (select id from sequence order by id desc limit 1) < 10 do


INSERT INTO sequence (name,deposit_date,deposit_amount,interest_amount) 
select 
(select name from sequence order by id desc limit 1),
date_add((select deposit_date from sequence where  deposit_date order by id desc limit 1),INTERVAL 1 hour),
((select deposit_amount from sequence where  deposit_amount order by id desc limit 1) + (select interest_amount from sequence where  interest_amount order by id desc limit 1)),
(select deposit_amount from sequence where id='1')* 0.04 /12;


end while;
end //
delimiter ;

call pro();

update sequence 
set deposit_amount = 10000000
where id = 2;


select * from sequence;

 

 

 order by limit 1

를 쓰는 것보다 max가 좀더 빠르다는 얘기를 들음

내일 수정해봐야겠다

 

728x90
728x90

https://stepby-yun.tistory.com/191

 

mysql procedure 프로시저 생성 및 실행 (구본문자 DELIMITER )

while문 해보려는데.. 나와같은 의문을 가지신 분 프로시저 꼭 만들어서 써야돼? https://stackoverflow.com/questions/12954095/mysql-declare-while-outside-stored-procedure-how mysql DECLARE WHILE outside..

stepby-yun.tistory.com

지난시간...

while문 해보려다가 프로시저로 감싸야한다길래 그거 공부했다.

 

다시 while문 해보자~

 

 

create procedure pro(i int)
begin 
while i < 5 do
insert into sequence (interest_amount) values (i);
set i = i +1;
end while;
end
//
DELIMITER ;

call pro(0);

 

 

 

 

 

 

커맨트 창에 명령어입력할때 한 줄씩 넣어야 작동하네...

while 기본적인 거 했으니까 과제해보기

 

 

1시간씩 이자액 증가하기 

명령문 실행했을 때

기준 시간보다 몇 시간 지나있으면 그 몇시간 만큼 이자액 증가. 

 

 

DELIMITER //

create procedure pro(i)

while   if (기준시간 + 1 분 * i) > 기준시간 ,이면 실행한다.   do

이자액 증가 실행 

insert into sequence (interest_amount) values (증가한 이자액 넣기);

set i = i+1;

end while

end

 

//
DELIMITER ;

 

 

call pro(0)

 

 

 

0부터 시작해서 

기준시간

 

 

 

----

몇분이 지났는지는 

금액으로 넣어줘야되려나?

 

 

 

조건은 1분씩 이자액이 들어갈거임

 

지금시간보다 1분증가

현재시간이 기준시간보다 n분이상이면

if now >

n분 증가할때마다 이자율 증가

 

 

https://ponyozzang.tistory.com/697

 

MySQL 날짜, 시간 계산 DATEDIFF, TIMEDIFF 사용 방법

MySQL에서 날짜 함수를 사용해 날짜 또는 시간 게산을 하는 방법을 알아보겠습니다. 날짜와 시간 계산에 관련된 함수가 어떤 것이 있는지 먼저 간단히 보겠습니다. DATEDIFF() - 두 기간 사이의 일수

ponyozzang.tistory.com

SELECT * FROM test.sequence;
drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while @min < 30 do
set @min = minute((SELECT TIMEDIFF(now(),'2022-05-11 10:30:00')));
set @deposit_amount =(select deposit_amount from sequence where id='1');
select @min;
insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
end while;
end //
delimiter ;

call pro();

 

오 뭔가 함 근데 계속 들어가!!!!

1분 지났을때만 추가되어야하는데..

 

 

SELECT * FROM test.sequence;
truncate sequence;

insert into sequence (name,deposit_date,deposit_amount) values ('이소윤','20200509','10000000');

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while @min <10 do
set @min = minute(   (SELECT TIMEDIFF(now(),'2022-05-11 11:48:00'))   );
set @deposit_amount =(select deposit_amount from sequence where id='1');
select @min;
insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
end while;
end //
delimiter ;

call pro();



1분마다 바뀌어야하는데 초 차이날때마다 업데이트됨

워크벤치에서 한번에 실행하고 싶은데 왜 cmd에서는 잘되어도 워크벤치는null값으로 계속 찍힐까?

 

 

 

계속 찍힘 이렇게..

-------------------

 

SELECT * FROM test.sequence;SELECT * FROM test.sequence;
truncate sequence;

insert into sequence (name,deposit_date,deposit_amount) values ('이소윤','20200509','10000000');

drop procedure if exists pro;
delimiter //
create procedure pro()
begin

set @deposit_amount =(select deposit_amount from sequence where id='1');
while @min <10 do
set @min = minute(   (SELECT TIMEDIFF(now(),'2022-05-11 14:26:00'))   );
if ( @min /@min >0) then
insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
end if;
end while;

end //
delimiter ;

call pro();

 

----

 

set @lastTime = (select deposit_date from sequence where  deposit_date order by id desc limit 1);

 

만약, 이전분보다 1분 흘렀으면

if   (SELECT TIMEDIFF(now(),마지막행시간)) > '00:01:00'

set 흐른분 = minute(SELECT TIMEDIFF(now(),마지막행시간))

마지막행에 넣기 흐른분* 이자율 

 

 

////////////////

SELECT * FROM test.sequence;SELECT * FROM test.sequence;
truncate sequence;
set @test = (select subtime(now(),'00:02:00'));
insert into sequence (name,deposit_date,deposit_amount) values ('이소윤',@test,'10000000');

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while @min <30 do
set @interestAmount = (select interest_amount from sequence);

if   (SELECT TIMEDIFF(now(),@lastTime)) > '00:01:00' then
set @lastTime = (select deposit_date from sequence where  deposit_date order by id desc limit 1);
set @min = minute(   (SELECT TIMEDIFF(now(),@lastTime))   );
if ( @interestAmount !=  @interestAmount) then
insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
end if;
end if;
end while;
end //
delimiter ;

call pro();

 

 

 

///////////

SELECT * FROM test.sequence;SELECT * FROM test.sequence;
use test;
truncate sequence;
set @test = (select subtime(now(),'00:02:00'));
insert into sequence (name,deposit_date,deposit_amount) values ('이소윤',@test,'10000000');

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
while  do
set @min = minute(   (SELECT TIMEDIFF(now(),(select deposit_date from sequence where  deposit_date order by id desc limit 1)))   );
set @interestAmount = (select interest_amount from sequence where interest_amount order by id desc limit 1);

if    @min > '0' then
insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
if ( @interestAmount !=  @interestAmount) then
insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
end if;

end if;
end while;
end //
delimiter ;

call pro();

 

/////////////

 

------------

 

 

 

마지막에서 1꺼

마지막에서 2한번더 들어간거!

이렇게 

수정해야겠다. 왜냐면 

id=2부터 이자액 들어가니까

 

use test;
truncate sequence;

set @setTime = (select subtime(now(),'00:02:00'));
insert into sequence (name,deposit_date,deposit_amount) values ('이소윤',@setTime,'10000000');

drop procedure if exists pro;
delimiter //
create procedure pro()
begin
set @min = minute((SELECT TIMEDIFF(now(), @setTime)));
set i =1;

while i <= @min do
set i = i +1;
set @interest_amount = (select interest_amount from sequence where  interest_amount order by id desc limit 2);
set @Prev_interest_amount = (select interest_amount from sequence where  interest_amount order by id desc limit 3);

if (@interest_amount != @Prev_interest_amount) then 
 insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
end if;
end while;
end //
delimiter ;

call pro();

 

흑흑 안돼...

 

 

왜 삭제 안되지?????

 

 

use  test;

를 빼먹었나 그거 하고 하니까 됨

 

 

/////

여러번으 시도를 했지만 안됨..

use test;
truncate sequence;


set @setTime = (select subtime(now(),'00:02:00'));
select @setTime;
insert into sequence (name,deposit_date,deposit_amount) values ('이소윤',@setTime,'10000000');
select * from sequence;

drop procedure if exists pro;
delimiter //
create procedure pro(i int)
begin
set @min = minute((SELECT TIMEDIFF(now(), @setTime)));
select @min;


while i <= @min do
set i = i +1;
select i;
set @interest_amount = (select interest_amount from sequence where  interest_amount order by id desc limit 1);
set @Prev_interest_amount = (select interest_amount from sequence where  interest_amount order by id desc limit 2);

if (@interest_amount != @Prev_interest_amount) then 
 insert into sequence (interest_amount) values (@min*(@deposit_amount*0.04/12));
end if;
end while;
end //
delimiter ;

call pro(1);
select * from sequence;

728x90

+ Recent posts