s;,'i ;c,i);
b[j]=-c;
for(k=0;k
while(a[i]!='\%d\t"
b[j]=c ;
b[j 1]=a[i]-'0';6'}
return c,k=0;
}
int len(char a[])
{ int i=0;,'9',c;)
{
if(a[i 1]==a[i])
{
c=c1(a,i);stdio;9'k )
{b[j 1]=a[i]-',j=0;2','9'
while(a[i 1]!=a[i])
{c ;};9'6'
int i=0;,'\0')
i ;
return i;
}
main()
{int b[100].h"
int c1(char a[],int i)
{int c=1;}
return c;,','
while(a[i];,','6'!=','0','
}
s=len(b);
for(j=0;j
i ;j ;}
}
i =c;
char a[100]={'
while(a[i 1]==a[i])
{c ;,'8','
}
int c2(char a[],int i)
{int c=0;,'3'7','5'1'5'2'#include "i ;
i ;j ;
}
else
{ c=c2(a;,'0'5's;j )
printf("
After the database is used for a period of time, there will often be too much free space in the database due to data deletion. In this case, it is necessary to reduce the disk space allocated to the database file and transaction log file to avoid wasting disk space. When there is no data in the database, you can modify the database file attributes to directly change its occupied space. However, when there is data in the database, doing so will destroy the data in the database, so compression is needed to reduce the database space. You can select the "Auto shrink" option in the database property options to let the system automatically compress the database, or you can compress it manually. There are two ways to manually compress the database:
1. Use Enterprise Manager to compress the database
In Enterprise Manager, right-click on the database to be compressed and select the "Shrink Database" option from "All Tasks" in the shortcut menu
, Use Transact-SQL command to compress the database
You can use the DBCC SHRINKDATABASE and DBCC SHRINKFILE commands to compress the database. The DBCC SHRINKDATABASE command compresses the database, and the DBCC SHRINKFILE command compresses the files specified in the database.
(1) DBCC SHRINKDATABASE
The DBCC SHRINKDATABASE command syntax is as follows:
DBCC SHRINKDATABASE (database_name [, target_percent]
[, {NOTRUNCATE | TRUNCATEONLY}] )
Each parameter is explained as follows:
target_percent specifies what percentage of the database size the unused space will account for after the database is compressed. If the specified percentage is too large and exceeds the proportion of unused space before compression, the database will not be compressed. And the compressed database cannot be smaller than the initial capacity of the database.
NOTRUECATE
Keep the remaining space after the database is reduced in the database and will not return it to the operating system. If you do not select this option, the remaining space is returned to the operating system.
TRUNCATEONLY
Return the remaining space after the database is reduced to the operating system. When you use this command, SQL Server shrinks the file area to the last file allocation, but does not move any data files. When this is selected, the target_percent option has no effect.
The unused space of the compressed database mytest is 20% of the database size.
dbcc shrinkdatabase (mytest, 20)
The running results are as follows:
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
(2) DBCC SHRINKFILE
The DBCC SHRINKFILE command compresses files in the current database. Its syntax is as follows:
DBCC SHRINKFILE ( {file_name | file_id }
{ [, target_size] |
[, {EMPTYFILE | NOTRUNCATE | TRUNCATEONLY}] } )
Each parameter is explained as follows:
file_id
Specify the identification number (ID) of the file to be compressed. The file ID number can be obtained through the FILE_ID() function or the Sp_helpdb system stored procedure described earlier in this chapter.
target_size
Specify the compressed size of the file. Measured in MB. If you do not specify this option, SQL Server will shrink the file as much as possible.
EMPTYFILE
Indicates that this file is no longer used and all data in this file will be moved to other files in the same file group. After executing the command with this parameter, the file can be deleted using the ALTER DATABASE command.
The remaining parameters NOTRUNCATE and TRUNCATEONLY have the same meaning as in the DBCC SHRINKDATABASE command.
Example: Compress the size of the database file mydb_data2 in the database mydb to 1MB. use mydb dbcc shrinkfile (mydb_data2, 1)
The above is the detailed content of Urgent help: Write a basic C language data compression program!. For more information, please follow other related articles on the PHP Chinese website!