This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 再问个SQL问题(发现原来不好好学习,现在问题越来越多)原来干活就会依葫芦画瓢,今天老板在让我帮忙弄个比较变态的SQL SCRIPT的时候,突然问了我一句,SQL语句能不能定义变量和函数?我立马傻了,好象从来没看见过,但不敢说没有,因为我从来没有系统地学习过SQL,请问高手们,到底有没有啊?
:)
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
{228}
(#836214@0)
-
我以为你先说明用的什么数据库比较好,不然高手也无从下手
-xiagangle(xiagangle);
2002-11-4
(#836256@0)
-
你可以举INFORMIX,MS SQL, ACCESS的例子
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836320@0)
-
看你怎么定义SQL语言了。
-guestagain(guest again);
2002-11-4
(#836259@0)
-
看不太懂
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836321@0)
-
如果是标准的SQL,比如SQL92,不行,如果是各数据库厂商的增强了的SQL,如:T-SQL,PL/SQL等,那是另一回事。
-guestagain(guest again);
2002-11-4
(#836527@0)
-
For oracle, only by SQL, No. By PL/SQL, yes
-tongcd(programmer);
2002-11-4
(#836346@0)
-
单从ORACLE如果不行的话,估计INFORMIX也做不到了,另外什么是PL/SQL?
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836352@0)
-
Informix在Stored Procedure里可以
-pasu(InTheSky);
2002-11-4
(#836368@0)
-
那好象是做进了数据库结构里面了,我是在想能不能在sql script里面写变量和函数
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836373@0)
-
for SQL Server, you can define the variable in any batch script, but the user-defined function is only supported by version 2000.
-yangn(Raymond);
2002-11-4
(#836462@0)
-
PL/SQL is used to write store procedure. The store procedure has to be invoked by SQL script on programming wise. I don't think you can get what you want only in SQL. A simple tutorial about PL/SQL
-tongcd(programmer);
2002-11-4
(#836429@0)
-
还是STORED PROCEDURE,确实STORED PROCEDURE能做到我想要的这几点,但是,STORED PROCEDURE是死的,而且如果设计过多的STORED PROCEDURE 会影响数据库的效率
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836445@0)
-
The performance tuning is not just that.For example, you have to update 1000 record at same time. By sql script, there would be 1000 thousand round trip between database server and your application, but by PL/SQL, it will be done in one trip. Besides, PL/SQL can be pre-compiled.
Yes, stored procedure is not always a good choice. Because that means build the business logic in the database, which means it is poor extensibility and maintainability. This is a trade-off.
-tongcd(programmer);
2002-11-4
{432}
(#836467@0)
-
我没有反对STORED PROCEDURE啊,确实STORED PROCEDURE是编译好的,运行速度大大高于SQL SCRIPT,我的意思只是不愿意为比较灵活的应用设计STORED PROCEDURE
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836569@0)
-
Agree. but somtimes you have to
-tongcd(programmer);
2002-11-4
(#836582@0)
-
我用4GL很方便的把那些变态的SQL完成不了的东西变成现实,但老板连VI都不喜欢,说喜欢NOTEPAD,那我就不能再强求他去学4GL了
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836594@0)
-
4GL……长得忒象Fox了,嘿嘿。
-pasu(InTheSky);
2002-11-5
(#836831@0)
-
No matter which database system you wanna use, the business logic and the db performance are totally different issues to be considered. You can't say the number of sp impacts the performance.
-yangn(Raymond);
2002-11-4
(#836493@0)
-
过多的SP肯定影响性能,SP是编译好的,要占内存的,过多的SP,会引起频繁的内存和硬盘的数据交换,而且很不明白你的BUSINESS LOGIC和数据库的性能没有关系这句话,如果你单和整个数据库系统的性能确实没有什么关系,和单个数据库,当然关系就大了
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
{206}
(#836577@0)
-
没的事,共享内存给大点就好了。这年头,还会省那点RAM吗?
-pasu(InTheSky);
2002-11-4
(#836585@0)
-
support
-hugefox(长得象熊的狐狸);
2002-11-4
(#836607@0)
-
这么说就不对了,还要DBA干嘛,都要硬件工程师不就得了
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836611@0)
-
2个回滚段和4个回滚段的区别硬件工程师是不知道的啊
-hugefox(长得象熊的狐狸);
2002-11-4
(#836624@0)
-
这位朋友,你的概念有错误。
1。每一个SP,占用的MEM不过几十KB,在今天1GB的MEM几乎成为DB SERVER的基本配置的情况下,几乎可以忽略不计2。不知你说的会引起频繁的内存和硬盘的数据交换是什么意思,SP占用的是PROCEDURE CACHE,和DATA CACHE完全是两回事。自然execute sp会对database产生读,写操作,但这是由其中的sql statement引起的,不能说SP数量越多,对DB的性能影响越大。
3。我们写SP主要是从BUSINESS LOGIC 来考虑的,但不能说过多的SP肯定影响性能。应该说写的不当的SP会影响PERFORMANCE,但这和其数量没有必然的关系。
-yangn(Raymond);
2002-11-4
{364}
(#836635@0)
-
没错,SP最不好的我觉得其实是影响可移植性。不过也没有啥大不了的,谁一天没事老换平台啊,呵呵。
-pasu(InTheSky);
2002-11-5
(#836819@0)
-
#836569
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836859@0)
-
check your email after I restart my pc.
-henhen(哼哼~~,找工ing~~~~);
2002-11-4
(#836451@0)