The invention relates to a locking and releasing device of a transmission shaft for an automatic goods shelf. The locking and releasing device comprises the goods shelf, wherein the transmission shaft is arranged on the goods shelf. The locking and releasing device is characterized in that a bracket rod is arranged on the goods shelf on the lower side of the transmission shaft; the bracket rod is parallel to the transmission shaft; levers are hinged to the bracket rod; gears are fixed in the positions, corresponding to the levers, of the transmission shaft; racks are arranged in the positions, below the gears, of the levers; when the gravity centers of the levers are positioned on the side, away from the transmission shaft, of the bracket rod, the gears on the transmission shaft mesh with the racks on the levers through the gravity action of the levers; when the gravity centers of the levers are positioned on the side, close to the transmission shaft, of the bracket rod, an extension spring is connected between the ends, away from the transmission shaft, of the levers and the goods shelf below the levers, and the gears on the transmission shaft mesh with the racks on the levers through the tension action of the extension spring. According to the device, the transmission shaft of the automatic goods shelf can be effectively locked, goods are prevented from moving or sliding, the structure is simple, the mounting space is small, the processing cost is low, and the automation requirement can be met.