Simple thing if you want to have min
and max
in SQL query.
ROUND((RAND() * (max-min))+min)
Simple thing if you want to have min
and max
in SQL query.
ROUND((RAND() * (max-min))+min)
If you would like to dump all tables and triggers and stuff try this one:
mysqldump -uUSER -p -R --opt --triggers DB > DB_DUMP.sql
but if you have some troubles with permissions for locking tables use --lock-tables=false
mysqldump -uUSER -p -R --opt --triggers --lock-tables=false DB > DB_DUMP.sql
and to dump all databases you have
mysqldump -uUSER -p -R --opt --triggers --lock-tables=false --all-databases > DB_DUMP.sql
also, great post on StackExchange with a script for dumping all databases without databases like `mysql`, `information_schema`, `performance_schema`, `sys`.
MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
#
# Collect all database names except for
# mysql, information_schema, and performance_schema
#
SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN"
SQL="${SQL} ('mysql','information_schema','performance_schema')"
DBLISTFILE=/tmp/DatabasesToDump.txt
mysql ${MYSQL_CONN} -ANe"${SQL}" > ${DBLISTFILE}
DBLIST=""
for DB in `cat ${DBLISTFILE}` ; do DBLIST="${DBLIST} ${DB}" ; done
MYSQLDUMP_OPTIONS="--routines --triggers --single-transaction"
mysqldump ${MYSQL_CONN} ${MYSQLDUMP_OPTIONS} --databases ${DBLIST} > all-dbs.sql