{"id":537,"date":"2025-07-28T09:40:50","date_gmt":"2025-07-28T00:40:50","guid":{"rendered":"https:\/\/sejiwon.com\/?p=537"},"modified":"2025-07-28T09:40:50","modified_gmt":"2025-07-28T00:40:50","slug":"shirink-file%ec%9d%b4%eb%9e%80","status":"publish","type":"post","link":"https:\/\/sejiwon.com\/?p=537","title":{"rendered":"shirink file\uc774\ub780"},"content":{"rendered":"\n<p><code>SHRINKFILE<\/code>\uc740 SQL Server\uc5d0\uc11c <strong>\ub370\uc774\ud130\ubca0\uc774\uc2a4 \ud30c\uc77c(\uc608: MDF, NDF, LDF)<\/strong> \uc758 <strong>\ubb3c\ub9ac\uc801\uc778 \ud06c\uae30\ub97c \uc904\uc774\ub294 \uba85\ub839\uc5b4<\/strong>\uc785\ub2c8\ub2e4. \ud2b9\ud788, <strong>\uc0ac\uc6a9\ub418\uc9c0 \uc54a\ub294 \uc5ec\uc720 \uacf5\uac04(free space)<\/strong> \uc744 \ud68c\uc218\ud558\uc5ec \ud30c\uc77c \ud06c\uae30\ub97c \uc904\uc774\ub294 \ub370 \uc0ac\uc6a9\ub429\ub2c8\ub2e4.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc <code>DBCC SHRINKFILE<\/code> \uc774\ub780?<\/h2>\n\n\n\n<p><code>DBCC SHRINKFILE<\/code>\uc740 \ud2b9\uc815 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \ud30c\uc77c\uc5d0\uc11c <strong>\uc0ac\uc6a9\ud558\uc9c0 \uc54a\ub294 \uacf5\uac04\uc744 \ubc18\ud658\ud558\uc5ec \ud30c\uc77c \ud06c\uae30\ub97c \uc904\uc774\ub294<\/strong> \uba85\ub839\uc5b4\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcda \ubb38\ubc95:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>DBCC SHRINKFILE (logical_file_name, target_size_in_MB);\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\uc778\uc790<\/th><th>\uc124\uba85<\/th><\/tr><\/thead><tbody><tr><td><code>logical_file_name<\/code><\/td><td><code>sys.database_files<\/code>\uc5d0 \ub098\uc624\ub294 \ud30c\uc77c\uc758 \ub17c\ub9ac\uc801 \uc774\ub984<\/td><\/tr><tr><td><code>target_size_in_MB<\/code><\/td><td>\ucd95\uc18c \ud6c4 \uc6d0\ud558\ub294 \ud30c\uc77c \ud06c\uae30(MB \ub2e8\uc704). SQL Server\ub294 \uac00\ub2a5\ud55c \ud55c \uc5ec\uae30\uc5d0 \uac00\uae5d\uac8c \ucd95\uc18c<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\udde0 \uc608\uc2dc<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>-- \ud30c\uc77c \uc774\ub984 \ud655\uc778\nSELECT name, type_desc, size * 8 \/ 1024 AS size_MB\nFROM sys.database_files;\n\n-- \uc608: 'MyDatabase'\uc758 \ub370\uc774\ud130 \ud30c\uc77c\uc744 200MB\ub85c \uc904\uc774\uae30\nUSE MyDatabase;\nDBCC SHRINKFILE (MyDataFile, 200);\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\uddf1 \uc791\ub3d9 \ubc29\uc2dd<\/h2>\n\n\n\n<ul>\n<li>SQL Server\ub294 \ub370\uc774\ud130 \ud30c\uc77c\uc5d0\uc11c <strong>\ub4a4\ucabd\uc758 \uc0ac\uc6a9\ub418\uc9c0 \uc54a\uc740 \ud398\uc774\uc9c0<\/strong>\ub97c \ucc3e\uc544\uc11c \uc55e\ubd80\ubd84\uc73c\ub85c <strong>\uc555\ucd95(compact)<\/strong> \ud558\uace0, \uadf8 \ub4a4\uc758 <strong>\ube48 \uacf5\uac04\uc744 \uc798\ub77c\ub0c4<\/strong><\/li>\n\n\n\n<li>\uc2e4\uc81c \ub370\uc774\ud130\uac00 \ucc28 \uc788\ub294 \uacf5\uac04\uc740 \uc904\uc77c \uc218 \uc5c6\uc74c \u2192 <strong>\uc555\ucd95\uc740 &#8220;\ube48 \uacf5\uac04&#8221;\uc5d0\ub9cc \uac00\ub2a5<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udfe1 \uc8fc\uc758 \uc0ac\ud56d<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\ubb38\uc81c<\/th><th>\uc124\uba85<\/th><\/tr><\/thead><tbody><tr><td>\u2757 \uc131\ub2a5 \uc800\ud558<\/td><td>SHRINK\ub294 \ub9ce\uc740 \ub514\uc2a4\ud06c I\/O \ubc1c\uc0dd, CPU\ub3c4 \uc0ac\uc6a9\ub428<\/td><\/tr><tr><td>\u2757 \uc778\ub371\uc2a4 \uc870\uac01\ud654<\/td><td>\uc778\ub371\uc2a4 \ud398\uc774\uc9c0\ub97c \ubb34\uc791\uc704\ub85c \uc774\ub3d9 \u2192 <strong>\uc2ec\uac01\ud55c \uc870\uac01\ud654<\/strong> \ubc1c\uc0dd<\/td><\/tr><tr><td>\u274c \uc790\uc8fc \uc0ac\uc6a9 \uae08\uc9c0<\/td><td>\uc8fc\uae30\uc801\uc778 SHRINK\ub294 \ube44\ud6a8\uc728\uc801\uc774\uace0 \uc624\ud788\ub824 \uc131\ub2a5\uc5d0 \uc545\uc601\ud5a5<\/td><\/tr><tr><td>\u2705 \uc720\uc9c0\ubcf4\uc218 \ud6c4 \ub2e8\ubc1c\uc131 \uc0ac\uc6a9<\/td><td>\ub300\uc6a9\ub7c9 TRUNCATE, \uc0ad\uc81c \ud6c4 \ud55c \ubc88 SHRINK\ud558\ub294 \uac74 OK<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc \uc0ac\uc6a9 \uc2dc\uc810<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\uc0c1\ud669<\/th><th>SHRINKFILE \uc0ac\uc6a9 \uc5ec\ubd80<\/th><\/tr><\/thead><tbody><tr><td>\u2705 \ub300\uc6a9\ub7c9 \ub370\uc774\ud130 \uc0ad\uc81c\/TRUNCATE \ud6c4<\/td><td>\uac00\ub2a5<\/td><\/tr><tr><td>\u2705 \ubc31\uc5c5 \uc804 \uc77c\uc2dc\uc801\uc73c\ub85c \uacf5\uac04 \uc904\uc774\uae30<\/td><td>\uac00\ub2a5<\/td><\/tr><tr><td>\u274c \uc815\uae30\uc801\uc73c\ub85c \uc0ac\uc6a9<\/td><td>\ube44\uad8c\uc7a5<\/td><\/tr><tr><td>\u274c \uacf5\uac04\uc774 \uace7 \ub2e4\uc2dc \ud544\uc694\ud560 \uc608\uc815\uc77c \ub54c<\/td><td>\ube44\ud6a8\uc728\uc801 (\ucd95\uc18c \u2192 \ub2e4\uc2dc \ud655\uc7a5\ub428)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \uc790\uc8fc \ud568\uaed8 \uc4f0\ub294 \ucffc\ub9ac<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>-- \uc0ac\uc6a9 \uc911\uc778 \uacf5\uac04\uacfc \uc804\uccb4 \uacf5\uac04 \ud655\uc778\nSELECT \n    name AS LogicalName,\n    size * 8 \/ 1024 AS SizeMB,\n    FILEPROPERTY(name, 'SpaceUsed') * 8 \/ 1024 AS UsedMB\nFROM sys.database_files;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udfaf \uc694\uc57d<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\ud56d\ubaa9<\/th><th>\uc124\uba85<\/th><\/tr><\/thead><tbody><tr><td>\ubaa9\uc801<\/td><td>\ud30c\uc77c \ud06c\uae30 \uc904\uc5ec \ub514\uc2a4\ud06c \uacf5\uac04 \ud68c\uc218<\/td><\/tr><tr><td>\ub300\uc0c1<\/td><td>\ub370\uc774\ud130 \ud30c\uc77c(MDF, NDF) \ub610\ub294 \ub85c\uadf8 \ud30c\uc77c(LDF)<\/td><\/tr><tr><td>\uba85\ub839\uc5b4<\/td><td><code>DBCC SHRINKFILE<\/code><\/td><\/tr><tr><td>\uc704\ud5d8<\/td><td>\uc778\ub371\uc2a4 \uc870\uac01\ud654, \uc131\ub2a5 \uc800\ud558<\/td><\/tr><tr><td>\uad8c\uc7a5 \uc0ac\uc6a9<\/td><td><strong>\uc815\ub9ac \ud6c4 1\ud68c\uc131 SHRINK\ub9cc!<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>SHRINKFILE\uc740 SQL Server\uc5d0\uc11c \ub370\uc774\ud130\ubca0\uc774\uc2a4 \ud30c\uc77c(\uc608: MDF, NDF, LDF) \uc758 \ubb3c\ub9ac\uc801\uc778 \ud06c\uae30\ub97c \uc904\uc774\ub294 \uba85\ub839\uc5b4\uc785\ub2c8\ub2e4. \ud2b9\ud788, \uc0ac\uc6a9\ub418\uc9c0 \uc54a\ub294 \uc5ec\uc720 \uacf5\uac04(free space) \uc744 \ud68c\uc218\ud558\uc5ec \ud30c\uc77c \ud06c\uae30\ub97c \uc904\uc774\ub294 \ub370 \uc0ac\uc6a9\ub429\ub2c8\ub2e4. \ud83d\udccc DBCC SHRINKFILE \uc774\ub780? DBCC SHRINKFILE\uc740 \ud2b9\uc815 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \ud30c\uc77c\uc5d0\uc11c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\ub294 \uacf5\uac04\uc744 \ubc18\ud658\ud558\uc5ec \ud30c\uc77c \ud06c\uae30\ub97c \uc904\uc774\ub294 \uba85\ub839\uc5b4\uc785\ub2c8\ub2e4. \ud83d\udcda \ubb38\ubc95: DBCC SHRINKFILE (logical_file_name, target_size_in_MB); \uc778\uc790 \uc124\uba85 logical_file_name sys.database_files\uc5d0 \ub098\uc624\ub294 \ud30c\uc77c\uc758\u2026 <span class=\"read-more\"><a href=\"https:\/\/sejiwon.com\/?p=537\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts\/537"}],"collection":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=537"}],"version-history":[{"count":1,"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts\/537\/revisions"}],"predecessor-version":[{"id":539,"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts\/537\/revisions\/539"}],"wp:attachment":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}