Primary keys in Database are essential for many reasons; they maintain entity integrity and help the database work faster when searching or linking data.
Sometimes, the primary keys aren't set for some tables. It's better to create the keys for these tables for better performance and integrity.
The following SQL query list all tables without Primary Key in a specific Database (<database_name>):
SELECT
TABLE_SCHEMA as 'Database',
TABLE_NAME as 'Table',
TABLE_ROWS as 'Row Count'
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = '<database_name>'
AND TABLE_TYPE = 'BASE TABLE'
AND TABLE_NAME NOT IN (
SELECT TABLE_NAME
FROM information_schema.TABLE_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'PRIMARY KEY'
AND TABLE_SCHEMA = '<database_name>'
)
ORDER BY TABLE_ROWS DESC;
just replace <database_name> by your database name.