我有一个名为的数据库apsc,如果我运行SHOW TABLES;它,这些是结果:
mysql> show tables;
+------------------------------------+
| Tables_in_apsc |
+------------------------------------+
| aps_application |
| aps_application_backup |
| aps_application_resource |
| aps_package |
| aps_package_configuration |
| aps_package_global_setting |
| aps_package_resource_configuration |
| aps_package_resource_setting |
| aps_package_series |
| aps_package_service |
| aps_registry_object |
| aps_registry_object_setting |
| aps_registry_object_tag |
| aps_resource |
| aps_resource_backup |
| aps_resource_requirement |
| aps_resource_requirement_backup |
| aps_settings_sequenses |
+------------------------------------+
18 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
但是,如果我跑,SELECT * FROM aps_application …
我们的用户以相当低级别的用户身份登录到生产数据库,在数据库级别授予SELECT,并在他们需要访问的特定表上授予INSERT/UPDATE/DELETE.
他们还有权创建临时表(我们需要它们来处理一些更复杂的查询).问题是虽然他们可以创建临时表,但他们无法访问INSERT!
我们找到的一种解决方法是创建一个同名的"真实"(持久?)表(但只有一个字段)并授予它们插入其中的访问权限.然后,当使用相同的名称创建临时表时,系统将使用该表,而不是持久表.
mysql> CREATE TEMPORARY TABLE `testing` (`id` INTEGER AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(30));
Query OK, 0 rows affected (0.04 sec)
mysql> INSERT INTO `testing` (`name`) VALUES ('testing');
ERROR 1142 (42000): INSERT command denied to user 'stduser'@'office.companyname.co.uk' for table 'testing'
Run Code Online (Sandbox Code Playgroud)
如果您尝试授予对表的访问权限(在另一个会话中,以root用户身份),则不能:
mysql> GRANT INSERT ON testdb.testing TO 'stduser'@'%';
ERROR 1146 (42S02): Table 'testdb.testing' doesn't exist
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,基本上,我们可以在临时表上授予INSERT/UPDATE/DELETE,而不会挂起同名的"持久"表吗?
当我查看我的Magento商店的错误日志时,它充满了以下错误:
[02-Jun-2011 13:49:12] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite_mysite.core_file_storage' doesn't exist' in /home/mysite/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/mysite/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/mysite/public_html/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/mysite/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/mysite/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `e`.* FR...', Array)
#4 /home/mysite/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(337): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `e`.* FR...', Array)
#5 /home/mysite/public_html/lib/Zend/Db/Adapter/Abstract.php(753): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /home/mysite/public_html/app/code/core/Mage/Core/Model/Mysql4/File/Storag in /home/mysite/public_html/lib/Zend/Db/Statement/Pdo.php on line 234
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
我正在使用spring,所有带注释的实体类信息都放在ApplicationContext.xml中.我正在使用MySql数据库,现在如何在hibernate中使用SchemaExport函数来创建表?我的应用程序无法自动创建表,虽然我已设置<prop key="hbm2ddl.auto">create</prop>.这是我的ApplicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql:///edde" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.edde.Book</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="current_session_context_class">thread</prop>
<prop key="show_sql">true</prop>
<prop key="hbm2ddl.auto">create</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean> …Run Code Online (Sandbox Code Playgroud) 这个问题是基于这个线程。
我运行失败
sudo mysql
\. /users/cs/SO_db/posts.sql
Run Code Online (Sandbox Code Playgroud)
我收到错误
ERROR 1146 (42S02): Table 'personal.posts' doesn't exist
Run Code Online (Sandbox Code Playgroud)
五个字符的 SQLSTATE 值 ('42S02')。这些值由 ANSI SQL 和 ODBC 指定,并且更加标准化。并非所有 MySQL 错误号都映射到 SQLSTATE 错误代码。值“HY000”(一般错误)用于未映射的错误。
和
错误:1146 SQLSTATE: 42S02 (ER_NO_SUCH_TABLE)
消息:表“%s.%s”不存在
您如何解决该错误消息?
我从我的服务器获取json数据,将它们显示为一个表.
$('#queryFrom').ajaxForm({
dataType: 'json',
beforeSubmit: showRequest, // pre-submit callback
success: processJson,
error: function (xhr, ajaxOptions, thrownError){
$('#queryResult').html('<div class="ui-corner-all ui-state-error"><p><span class="ui-icon ui-icon-alert"></span>'+thrownError+'</p></div>');
$('#queryResult').show("slow");
}
});
Run Code Online (Sandbox Code Playgroud)
我可以以某种方式将json/ajax erros方面的mysql错误分开吗?目前我得到:无效的JSON:SQLSTATE [42S02]:未找到基表或视图:1146表'simover.simulation'不存在{} 我可以自定义jquery引发的消息吗?谢谢阿曼.
编辑
可以使用xhr.responceTxt而不是thrownError.
抱歉长POST:我是否有可能从MySQL中的另一个存储过程调用存储过程.例如:我有两个表(test和testcomp):具有以下结构:
testCREATE TABLE IF NOT EXISTS `test` (
`t_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`t_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Run Code Online (Sandbox Code Playgroud)
和
testcompCREATE TABLE IF NOT EXISTS `testcomp` (
`c_id` int(11) NOT NULL AUTO_INCREMENT,
`t_id` int(4) NOT NULL,
`place` varchar(255) NOT NULL,
PRIMARY KEY (`c_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
Run Code Online (Sandbox Code Playgroud)
现在我填充测试表:
INSERT INTO `test` (`t_id`, `name`) VALUES
(1, 'foo'),
(2, 'bar'),
(3, 'ma');
Run Code Online (Sandbox Code Playgroud)
和table testcomp:
INSERT INTO `testcomp` …Run Code Online (Sandbox Code Playgroud) 发生了这个奇怪的错误我正在尝试清理我没有使用的数据库.但是,当我尝试删除mysql时,它说数据库dosnt存在,但是我可以使用它!奇怪还是什么?!从我的列表中删除这个数据库的任何方式.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use test;
Database changed
mysql> drop mysql;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql' at line 1
mysql> drop database mysql;
ERROR 1146 (42S02): Table 'mysql.proc' doesn't exist
mysql> …Run Code Online (Sandbox Code Playgroud) mysql macos mysql-error-1064 mysql-error-1146 mysql-error-1007