The invention discloses a method for generating a unique ID primary key through distributed software, the unique ID primary key is set as a CUID, the CUID comprises a prefix code Hi and a timestamp obtained through system time, and the prefix code Hi is a ULONG value obtained after hash calculation is carried out on a machine code and a program path. The method comprises the following steps: initializing a global prefix code Hi; Verifying the system time, checking whether a log file generated by the CUID last time exists locally or not, and skipping checking if the log file does not exist; ifthe log file is read, the log file is taken out, the timestamp for generating the CUID for the last time is analyzed, the current system time is compared, and if the time for generating the CUID for the last time is longer than the current system time, the log file is directly thrown out to be abnormal, and system operation is not allowed; obtaining the information of the SteID, distributing the SteID to each site, and enabling each deployed prefix code Hi to be unique; and generating a CUID value, and splicing the prefix code Hi and the character string of the current timestamp. The uniqueness of the generated ID is ensured.