create table test1 as select * from dba_objects; create table test2 as select * from dba_objects; create unique index test1_idx1 on test1(object_id); select * from test1; create table test3 as select object_id,object_name from test1 update test1 set…
下面直接上代码(copy到你的数据库里面直接就可以运行): CREATE PROCEDURE [dbo].[SP_UPDATE_LOG] ) AS BEGIN SET NOCOUNT ON; IF NOT EXISTS(SELECT * FROM sys.tables WHERE NAME = @TABLENAME AND TYPE = 'U' ) BEGIN PRINT'ERROR:not exist table '+@TABLENAME RETURN END IF (@TABLENAME L…
最近用PostgreSql数据库进行表关联更新时,发现与之前用的Sql Server 和My Sql语法有很大差别,稍微不注意,很容易出错. PostgreSql表更新时,两个表只允许一个表起别名,一般是被更新的表不起别名,查询的表起别名 正确的写法如下 SELECT * from pro.book; SELECT * from pro.book_detail; UPDATE pro.book_detail set book_name=tab1.book_name from pro.book t…
今天新搭建了一个10g的测试数据库,运行都很正常,但是在打开autotrace功能后执行语句,报错 SQL> set autotrace on SQL> select username,sid,serial#,server,paddr,status from v$session where username=USER; USERNAME SID SERIAL# SERVER PADDR STATUS ---------…