반응형
반응형

긴급취재 이태원 참사 - 후반부 - PD수첩 2022년11월1일 방송

https://www.youtube.com/watch?v=B9Q84TgHOls 

 

반응형
반응형

긴급취재 이태원 참사 - 전반부 - PD수첩 2022년11월1일 방송

https://www.youtube.com/watch?v=c8Da3yoay9I 

 

반응형
반응형

MSSQL 링크드서버,  linked server

 

MSSQL 은 연결된서버 기능을 제공하는데 이를 이용하면 다른 네트워크의 데이터베이스를 원격으로 접속하여

   사용할 수 있도록 해줍니다. 

-- MSSQL 연결된 서버 생성

EXEC sp_addlinkedserver
      @server = '[연결된 서버별칭]',
      @srvproduct = '',
      @provider = 'SQLOLEDB',
      @datasrc = '[서버 아이피]',
      @catalog = '[데이터 베이스명]'



-- MSSQL 연결계정 생성

EXEC sp_addlinkedsrvlogin
      @rmtsrvname= '[연결된 서버별칭]',
      @useself= 'false',
      @rmtuser = '[사용자 이름]',
      @rmtpassword = '[사용자 암호]'
      
      
-- MSSQL 연결된 서버 확인
   SELECT * FROM master.dbo.sysservers WHERE srvname = '[연결된 서버별칭]'
   

-- MSSQL 연결계정 확인
   SELECT * FROM master.sys.linked_logins WHERE remote_name = '[사용자 이름]'
   
   
-- MSSQL 연결된 서버 이용방법 
   /*연결된 서버를 등록한 후 사용하려면 [연결된 서버별칭].[데이터 베이스명].[데이터베이스 소유자명].[테이블명]
   형태로 호출하여 사용할 수 있습니다.
   SELECT 쿼리를 예로 들면 아래와 같습니다. */

 -- MSSQL 일반서버에 SELECT 쿼리시
   SELECT [컬럼명] FROM [테이블명] WHERE [조건절]

-- MSSQL 연결된 서버에 SELECT 쿼리시
   SELECT [컬럼명] FROM [연결된 서버별칭].[데이터 베이스명].[데이터베이스 소유자명].[테이블명] WHERE [조건절]

-- MSSQL 연결된 서버 삭제
  EXEC sp_dropserver
      @server = '[연결된 서버별칭]'

-- MSSQL 연결계정 삭제
   EXEC sp_droplinkedsrvlogin
      @rmtsrvname= '[연결된 서버별칭]',
      @locallogin = NULL
반응형
반응형

SQL Server 모든 테이블 크기를 조회하는 쿼리

테이블의 건수와, 테이블에 구성된 인덱스들의 합도 같이 확인할 수 있습니다.

SELECT
    OBJECT_SCHEMA_NAME(a2.object_id) AS SchemaName,
    a2.name AS TableName,
    a1.rows as [RowCount],
    CAST(ROUND(((a1.reserved + ISNULL(a4.reserved,0)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS ReservedSize_MB,
    CAST(ROUND(a1.data * 8 / 1024.00, 2) AS NUMERIC(36, 2)) AS DataSize_MB,
    CAST(ROUND((CASE WHEN (a1.used + ISNULL(a4.used,0)) > a1.data THEN (a1.used + ISNULL(a4.used,0)) - a1.data ELSE 0 END) * 8 / 1024.00, 2) AS NUMERIC(36, 2)) AS IndexSize_MB,
    CAST(ROUND((CASE WHEN (a1.reserved + ISNULL(a4.reserved,0)) > a1.used THEN (a1.reserved + ISNULL(a4.reserved,0)) - a1.used ELSE 0 END) * 8 / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSize_MB
FROM
    (SELECT 
        ps.object_id,
        SUM (CASE WHEN (ps.index_id < 2) THEN row_count ELSE 0 END) AS [rows],
        SUM (ps.reserved_page_count) AS reserved,
        SUM (CASE
                WHEN (ps.index_id < 2) THEN (ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count)
                ELSE (ps.lob_used_page_count + ps.row_overflow_used_page_count)
            END
            ) AS data,
        SUM (ps.used_page_count) AS used
    FROM sys.dm_db_partition_stats ps
    GROUP BY ps.object_id) AS a1
LEFT OUTER JOIN 
    (SELECT 
        it.parent_id,
        SUM(ps.reserved_page_count) AS reserved,
        SUM(ps.used_page_count) AS used
     FROM sys.dm_db_partition_stats ps
     INNER JOIN sys.internal_tables it ON (it.object_id = ps.object_id)
     WHERE it.internal_type IN (202,204)
     GROUP BY it.parent_id) AS a4 ON (a4.parent_id = a1.object_id)
INNER JOIN sys.all_objects a2  ON ( a1.object_id = a2.object_id ) 
WHERE a2.type <> N'S' and a2.type <> N'IT'
ORDER BY ReservedSize_MB DESC
반응형
반응형

The 10 Best Data Visualizations of 2022

https://towardsdatascience.com/the-10-best-data-visualizations-of-2022-3e49d7ccb832

 

The 10 Best Data Visualizations of 2022

Awesome visualizations on the Ukraine War, Inflation, and more!

towardsdatascience.com

Last year I shared what I thought were ten of the best data visualizations from 2021. I’m back again with ten of the best data visualizations from 2022!

Similar to last year, I wanted to share a variety of types of data visualizations, and also ones that were relevant with particular events that happened this year.

Let’s dive into it!

 

Be sure to SUBSCRIBE here to never miss another article on data science guides, tricks and tips, life lessons, and more!

 

1. NATO vs Russia

 

One of the biggest events this year was the war between Russia and Ukraine. Comforting or not, the infograph above shows the difference in military power between NATO and Russia. The actual data can be found here.

I love this infograph, it’s many pictographs combined into one, it’s clean, and it’s very clear what message it’s trying to convey.

NATO out-powers Russia in every aspect other than Nuclear Weapons… I wonder how this would change if Russia’s budget towards nuclear weapons went to other things 🤔.

 

Be sure to SUBSCRIBE here to never miss another article on data science guides, tricks and tips, life lessons, and more!

 

2. Inflation and the cost of everyday items

 

One of the consequences of the war between Russia and Ukraine is inflation. If you click on the visualization above, you’ll see how inflation has impacted our cost of every day items, like gas, coffee, and corn. (On the bright side, the cost of orange juice went down!)

If you’re interested, this type of data visualization is similar to a bar chart race, which is a dynamic bar chart shown over a period of time. If you want to build one yourself, here’s a tutorial that you can check out.

3. More on inflation and wages!

 

Every day items aren’t the only things affected by inflation, wages are also impacted by inflation. What does this mean? As inflation increases, the value of the dollar decreases, meaning our dollar doesn’t go as far as it used to.

This visualization is a dynamic line chart that shows how wage growth and inflation has changed since 2015. In 2021, for the first time since 2015, inflation surpassed wage growth.

4. School Shootings

 

Sometimes, a static bar chart is all you need to convey a message. This visualization shows the number of school shootings by country from 2009 to 2018. If this doesn’t imply that the US has a gun problem, I don’t know what does!

FYI, the US has 48 times more school shootings than the second highest country… fourty eight!

 

Be sure to SUBSCRIBE here to never miss another article on data science guides, tricks and tips, life lessons, and more!

 

5. What are people studying in school?

 

While we’re on the topic of school, the image above shows the fastest growing and shrinking fields of study in US colleges. STEM fields seem to make up the fastest growing fields, while arts and history fields seem to make up the fastest shrinking fields.

This data was provided by the U.S. Department of Education.

6. Time it takes for a hacker to brute force your password in 2022

 

Ever wonder why certain websites require a variety of characters and a minimum number ? This visualization shows the time that it takes a hacker to brute force your password in 2022.

What makes this visualization so powerful is how comprehensive it is — part of this is attributed to the colour scheme depending on how long it takes to brute for the password.

The data was compiled from How Secure is My Password and this was built using Illustrator and Excel.

7. Most popular web browsers over the last 28 Years

 

Now for the “Most Popular” visualizations of the year, this visualization shows the most popular web browsers over the last 28 years! As of March 2022, it’s no surprise that Google Chrome takes 80% of the market share, but that wasn’t the case back in the day.

This type of visualization is called a pie chart race, and it’s serves a similar purpose as as bar chart race, except that it’s more useful when you’re trying to emphasize proportions as opposed to absolute numbers.

The data used to build this was taken from the following sources:

  • W3Schools (Jul-99 to present)
  • WebSideStory (Feb-99 to Jun-06)
  • GVU WWW user survey (Jan-94 to Oct-98)
  • EWS Web Server at UIUC (Jun-96 to Dec-98)

8. Most Popular websites since 1993

 

The most popular web browsers is one thing, but the most popular websites is another. This visualization shows the most popular websites since 1993. What’s surprising is that Yahoo is still the ninth most visited website as of January 2022!

This type of data visualization is called a bar chart race. I’m sure you’ve seen many of these all over YouTube and Reddit.

9. Most spoken languages in the world

 

Another simple yet powerful visualization, this bar chart shows the most spoken languages in the world, with the top three being English, Mandarin, and Hindi.

This visualization was created using ggplot in R with data provided from Wikipedia.

 

Be sure to SUBSCRIBE here to never miss another article on data science guides, tricks and tips, life lessons, and more!

 

10. Biggest Fast Food Chains

 

For the last article, this visualization shows the top 50 biggest fast food chains based on the number of stores in the US. You can see that it’s split by “food category”, and within each category, the size of each restaurant represents its magnitude.

Who know that there were more Subways and Starbucks than McDonalds?

This visualization is called a treemap and is typically used when you want to visualize hierarchical and partitioned data. If you want to learn how to build one in Python, check out this link.

 

반응형
반응형

[MSSQL] DB 복구모델 - 전체(Full) 로 변경

 

복구 모델을 보려면

  1. 데이터베이스 엔진에 연결합니다.
  2. 표준 도구 모음에서 새 쿼리를 선택합니다.
  3. 다음 예제를 복사하여 쿼리 창에 붙여넣고 실행을 선택합니다. 이 예에서는 모델 데이터베이스의 복구 모델을 배우기 위해 sys.databases 카탈로그 뷰를 쿼리하는 방법을 보여줍니다.

 

복구 모델을 변경하려면

  1. 데이터베이스 엔진에 연결합니다.
  2. 표준 도구 모음에서 새 쿼리를 선택합니다.
  3. 다음 예제를 복사하여 쿼리 창에 붙여넣고 실행을 선택합니다. 이 예에서는 model ALTER DATABASE FULL 문의 SET RECOVERY 옵션을 사용하여 데이터베이스의 복구 모델을 로 변경하는 방법을 보여 줍니다.

 

-- 복구 모델을 보려면
SELECT name, recovery_model_desc  
   FROM sys.databases  
      WHERE name = 'model' ;  
 


-- 복구 모델을 변경하려면
USE [master] ;  
ALTER DATABASE [model] SET RECOVERY FULL ;

SSMS에서 하기. 

DB 속성에서 옵션 들어가서 복구모델 선택하기. 

 

단순(Simple) 데이터베이스 복구 모델을 선택하는 몇 가지 이유는 다음과 같습니다.

  • 개발 및 테스트 데이터베이스에 가장 적합합니다.
  • 데이터 손실이 허용되는 단순한 보고 또는 애플리케이션 데이터베이스
  • 장애 시점 복구는 전체 및 개별 백업 전용입니다.
  • 관리 오버헤드 없음

다음을 지원합니다.

  1. 전체 백업
  2. 차등 백업
  3. 복사 전용 백업
  4. 파일 백업
  5. 부분 백업

장점 : 고성능 대량 복사 작업이 가능하고 로그 공간을 확보하여 공간 요청을 작게 유지합니다.

단점 : 가장 최근의 데이터베이스 또는 불일치 백업을 다시 빌드해야 하므로 변경됩니다.

Full 

전체 복구 모델을 사용하면 SQL Server는 사용자가 백업할 때까지 트랜잭션 로그를 예약합니다. 이 복구 모델에서는 모든 거래(DDL(데이터 정의 언어) + DML(데이터 조작 언어))가 트랜잭션 로그 파일에 완전히 기록됩니다. 로그 순서는 손상되지 않고 데이터베이스가 작업을 복원할 수 있도록 보존됩니다. 단순 복구 모델과 달리 트랜잭션 로그 파일은 CHECKPOINT 작업 중에 자동으로 잘리지 않습니다.

데이터베이스 오류가 발생했을 때 전체 복구 모델을 사용하여 데이터베이스를 복원하는 가장 유연성을 얻을 수 있습니다. 지정 시간 복원, 페이지 복원 및 파일 복원을 포함한 모든 복원 작업이 지원됩니다.

전체 데이터베이스 복구 모델을 선택하는 이유:

  • 미션 크리티컬 애플리케이션 지원
  • 고가용성 키 설계
  • 0 또는 명목 데이터 손실로 모든 데이터 복구를 용이하게 하기 위해
  • 데이터베이스가 여러 파일 그룹을 갖도록 설계되었으며 읽기/쓰기 보조 파일 그룹 및 선택적으로 읽기 전용 파일 그룹의 부분적 복원을 수행하려는 경우
  • 임의 시점 복원 허용
  • 개별 시트 복원
  • 높은 관리 오버헤드 유지

다음을 지원합니다.

  1. 전체 백업
  2. 차등 백업
  3. 트랜잭션 로그 백업
  4. 복사 전용 백업
  5. 파일 및/또는 파일 그룹 백업
  6. 부분 백업

장점 : 데이터 파일의 유실 또는 손상으로 인한 작업 오작동이 없습니다. 임의의 시점으로 회복될 수 있습니다.

단점 : 로그가 손상되면 가장 최근의 로그 백업 이후의 변경 사항을 다시 작성해야 합니다.

데이터베이스가 개발 또는 테스트 서버인 경우 단순 복구 모델이 대부분 적합해야 합니다. 그러나 데이터베이스가 프로덕션 데이터베이스인 경우 일반적으로 전체 복구 모델을 사용하는 것이 좋습니다. 전체 복구 모델은 대량 로그 복구 모델로 보완할 수 있습니다. 물론 데이터베이스가 작거나 데이터 웨어하우스의 일부이거나 데이터베이스가 읽기 전용인 경우에도 마찬가지입니다.

반응형

+ Recent posts