资讯动态

常见数据库操作小记

发布时间:2026/10/16 4:06:50 来源:尧图企业网站定制
sqlserver操作建表create table tablename (columnname )增加一列 alter table tablename add columnname 字段类型修改一列 alter table tablename alter column columnname varchar(255)复制表insert into 新表名称 from 源表名称 where 11;跨表更新update table1 set val (select val from table2 where table1.idd table2.idd) where exists (select 1 from table2 where table1.idd table2.idd)死锁查询select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_typeOBJECT结束死锁kill spidOracle操作增加一列alter table tablename add test varchar2(10);修改一列alter table tablename modify test varchar2(20);删除一列alter table tablename drop column test;复制表create table 新表名称 as select * from 源表名称;死锁查询SELECT distinct l.session_id || ,|| s.serial# uniqueKey,l.session_id sid, s.serial# , l.locked_mode,l.oracle_username, l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time FROM v$locked_object l, all_objects o, v$session s WHERE l.object_id o.object_id AND l.session_id s.sid ORDER BY sid, s.serial# ;查询死锁用户的sql语句select b.username, b.serial#, d.id1, a.sql_text from v$lock d, v$session b, v$sqltext a where b.lockwait d.kaddr and a.address b.sql_address and a.hash_value b.sql_hash_value;结束死锁alter system kill session sid,serial#; uniqueKey

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价 →
↑