使用 Shell 脚本批量创建数据表 系统:Centos6.5 64位 MySQL版本:5.1.73 比如下面这个脚本: #!/bin/bash #批量新建数据表 for y in {0..199};do mysql -uroot -proot -e "use mysql; create table user$y( id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键,记录唯一标识', mail varchar(64) NOT NULL
这个例子演示了如何在shell脚本中执行多个sql来操作数据库表. #! /bin/sh USER_HOME=/home/`whoami` . /etc/profile if [ -f ${USER_HOME}/.bash_profile ]; then . ${USER_HOME}/.bash_profile fi mysql -h -ujifei30 -pNapnUszJD -Dtpssprod <<EOF select table_name from information_schema
shell脚本中sqlite3命令查询数据库失败返回空,并将错误信息打印到标准错误输出 如: #/bin/sh local ret='sqlite3 test.db "select test from test;"' 或: local ret=$(sqlite3 test.db "select test from test;") 如果test.db被锁定,ret将为空,标准错误输出有信息“Error:database is locked”.
--oracle删除数据库表(无主键)中重复的记录 1, CREATE TABLE newtable as SELECT distinct * FROM T_SYSTEM_MENU_PRIV; 2, drop table T_SYSTEM_MENU_PRIV; 3, ALTER TABLE newtable rename to T_SYSTEM_MENU_PRIV;