In many database applications, data have to be compressed before they can be stored. Data compression techniques with less overhead and better space saving are expected. This paper gives a data compression technique by which the size of a file may be reduced through substituting codes for its field values. The codes are the corresponding locations of the values in the hash table that is comprised of all the values of the field.The compression is effective for many applications, and the cost of the coding/decoding is equal to that of one access to the hash table. The implementation of the technique as a compression tool in DBMS for date storage and the algorithms of the coding/decoding are discussed.