对 MySQL 查询重写以提高性能是每个 DBA 应该意识到的重要过程,以便他们可以在运行时修复错误的查询,而无需在应用程序端更改代码。
到目前为止,MySQL 社区提供了两个内置的查询重写插件来执行此任务。
query rewriter plugin:它支持 INSERT / UPDATE / DELETE / REPLACE 语句,在 MySQL 8012 引入。
ddl_rewritter plugin:它支持 CREATE TABLE 语句。在 MySQL 8016 引入。
你在建立外键的时候要指定更新的关联,这样删除User中的一笔记录,所有以User表的UserId为外键的表的记录都会删除,修改User中UserId的值,所有所有以User表的UserId为外键的表的记录都会更新这个UserId的值
比如MSSQL中:
alter table tbl_xxx
add constraint FK_xxx foreign key (lodNo)
references tbl_aaa (loNo)
on update cascade on delete cascade
注意on update cascade on delete cascade
可以通过update(更新)语句实现给该记录 *** 作。sql:update tablename set username ='zhangsan' where id =5;
解释:因为改变的是某条记录,所以必定有where条件来限定到此条语句,上面的举例就是通过id的唯一性先确定此条记录,之后通过update将tablename表中的username字段值进行更新。
使用update语句\x0d\update 表名 set 列1名 = 列1值,\x0d\ 列2名 = 列2值, \x0d\ \x0d\where 条件
v$sql 是一个SYS级的视图。有ORACLE安装后自动从一个系统表上生成的视图。
create or replace view sysv_$sql as
select "SQL_TEXT","SQL_FULLTEXT","SQL_ID","SHARABLE_MEM","PERSISTENT_MEM","RUNTIME_MEM","SORTS","LOADED_VERSIONS","OPEN_VERSIONS","USERS_OPENING","FETCHES","EXECUTIONS","PX_SERVERS_EXECUTIONS","END_OF_FETCH_COUNT","USERS_EXECUTING","LOADS","FIRST_LOAD_TIME","INVALIDATIONS","PARSE_CALLS","DISK_READS","DIRECT_WRITES","BUFFER_GETS","APPLICATION_WAIT_TIME","CONCURRENCY_WAIT_TIME","CLUSTER_WAIT_TIME","USER_IO_WAIT_TIME","PLSQL_EXEC_TIME","JAVA_EXEC_TIME","ROWS_PROCESSED","COMMAND_TYPE","OPTIMIZER_MODE","OPTIMIZER_COST","OPTIMIZER_ENV","OPTIMIZER_ENV_HASH_VALUE","PARSING_USER_ID","PARSING_SCHEMA_ID","PARSING_SCHEMA_NAME","KEPT_VERSIONS","ADDRESS","TYPE_CHK_HEAP","HASH_VALUE","OLD_HASH_VALUE","PLAN_HASH_VALUE","CHILD_NUMBER","SERVICE","SERVICE_HASH","MODULE","MODULE_HASH","ACTION","ACTION_HASH","SERIALIZABLE_ABORTS","OUTLINE_CATEGORY","CPU_TIME","ELAPSED_TIME","OUTLINE_SID","CHILD_ADDRESS","SQLTYPE","REMOTE","OBJECT_STATUS","LITERAL_HASH_VALUE","LAST_LOAD_TIME","IS_OBSOLETE","CHILD_LATCH","SQL_PROFILE","PROGRAM_ID","PROGRAM_LINE#","EXACT_MATCHING_SIGNATURE","FORCE_MATCHING_SIGNATURE","LAST_ACTIVE_TIME","BIND_DATA" from v$sql;
从All_Objects t表中获取不到任何关于'%v$sql属组的信息,可见你无法对其进行删除 *** 作。
SELECT FROM All_Objects t WHERE tobject_name LIKE '%v$sql%';
以上就是关于数据库查询并修改数据全部的内容,包括:数据库查询并修改数据、如何修改数据库中主外键约束的数据、如何修改sql数据库里某个记录等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)