sql >> Base de Datos >  >> RDS >> Mysql

clave primaria compuesta (alfanumérica) e incremento automático

Pregunté esto hace un tiempo. Mysql no hace esto desafortunadamente. Me encantaría, pero simplemente no. En php podrías hacerlo. Ejemplo:

public function random_id_gen($length)
    {
        //the characters you want in your id
        $characters = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
        $max = strlen($characters) - 1;
        $string = '';

        for ($i = 0; $i < $length; $i++) {
            $string .= $characters[mt_rand(0, $max)];
        }

        return $string;
    }