|
How can I get the text of create table sql when I know the table name?
Is there any view I can query for?
for example
I create a table T in oracle database.
Can I get the text of its create table sql through oracle view?
"create table T (sno number(3,0) primary key);"
Many thanks.
|
|
|
|
|
Open query analyzer.
Press F8 if the object browser is not present.
Select your database and then right click on the appropriate table.
Cursor over Script Object To New Window As then select Create.
Regards
Guy
You always pass failure on the way to success.
|
|
|
|
|
My apologize. My meaning is to get it by command line,not by the ORACLE console.
Do you have any way in resolving it?
|
|
|
|
|
Hi,
i have a table of employee details where i have empno, name, salary.
i need to select the salary from the table in the descending order. the condition here is that I should not use order by clause.
If U Get Errors U Will Learn
If U Don't Get Errors U Have Learnt
|
|
|
|
|
Are you trying to do this in an inline query.
what is your actual requirement.
Regards
KP
|
|
|
|
|
u can use inline query . but my constraint is not to use order by clause
If U Get Errors U Will Learn
If U Don't Get Errors U Have Learnt
|
|
|
|
|
I could never see any reason for ever not using an order by clause to sort the output of a query.
The only other alternative I can think of is by setting the salary to be the primary key on a clustered index and see if that works.
This would of course be very bad design methodology as the empno field would make better sense as the primary key.
I would be more than happy to be proved wrong and am interested in what solution you come to.
Regards
Guy
You always pass failure on the way to success.
|
|
|
|
|
Try something like this:
<br />
CREATE TABLE #MyTempTable (salary decimal(28,12))<br />
INSERT INTO #MyTempTable <br />
SELECT salary FROM employeedetails<br />
GROUP BY salary <br />
<br />
CREATE INDEX salary <br />
ON #MyTempTable (salary DESC)<br />
<br />
SELECT * FROM #MyTempTable<br />
Regards
Guy
You always pass failure on the way to success.
modified on Friday, December 28, 2007 6:15:09 AM
|
|
|
|
|
Thanks Guy....
It sounds good.and this was the one i guessed....
If U Get Errors U Will Learn
If U Don't Get Errors U Have Learnt
|
|
|
|
|
This sounds very suspiciously like homework to me. We don't actually do your homework for you, so you'd better let us know what you've tried beforehand.
|
|
|
|
|
for (...) {
s.Format("%s",toInsert);
pConn.Execute(...);
}
Sometimes toInsert contains single quotation mark(s), how to do deal with it efficiently?
Thanks very much.
|
|
|
|
|
followait wrote: Sometimes toInsert contains single quotation mark(s), how to do deal with it efficiently?
Use parameterized query
|
|
|
|
|
Could give me some more guide?
pCmd->CommandText=_bstr_t(L"INSERT INTO tmp(id,a,b,c) "
L"VALUES(?,?,?,?)");
Like this, how to go on?
Thanks.
modified on Thursday, December 27, 2007 8:22:18 AM
|
|
|
|
|
followait wrote: pCmd->CommandText=_bstr_t(L"INSERT INTO tmp(id,a,b,c) "
L"VALUES(?,?,?,?)");
In VC I don't know. C# it could be
INSERT INTO tmp(id,a,b,c) VALUES(@id,@a,@b,@c)
CommandObject.Parameters.Add(@id,value);
CommandObject.Parameters.Add(@a,value);
CommandObject.Parameters.Add(@b,value);
CommandObject.Parameters.Add(@c,value);
|
|
|
|
|
"select * from (select username,designation, count(*) as points from (select username,designation from messages union all select username,designation from replies) group by username,designation) order by points desc"
this query works fine with MS Access but not with SQL Server.
Through this query I am listing most active members of forum by counting no. of message and replies. Members are 2 types- Students & Professionals
PLZ.... Help..
|
|
|
|
|
hope you are getting error message at group by clause
if so, try this
select * <br />
from (select username,designation, count(*) as points <br />
from (select username,designation <br />
from messages <br />
union all <br />
select username,designation <br />
from replies<br />
)t1 <br />
group by username,designation<br />
)t2<br />
order by points desc
Regards
KP
|
|
|
|
|
Thanks a lot it worked for me..
I rated u 5
This is 4 u
|
|
|
|
|
Try:
select * from (
select username, designation, count(*) as points
from (
select username, designation from messages
union all
select username, designation from replies
) as A
group by username, designation
) as B
order by points desc You need to provide table aliases. I'm not sure where menber-types fit into this.
Regards
Andy
|
|
|
|
|
What is the exact purpose of this Query ???
If U Get Errors U Will Learn
If U Don't Get Errors U Have Learnt
|
|
|
|
|
I'm building a web application which has lots of users, each with lots of security rules. what is better???
1- to make a table for users and another table for permissions. and insure by coding(in ASP.NET for example) the security
2- to create for each user in the system new user in the DBMS itself and assign the security from the database.
Thanks in Advance
|
|
|
|
|
First one is better,because the users are specific to your application not your DB.
if u create a user in db even when ur Application is Down . hte users can access the DB directly and update the DB.
use the Design which is specific to ur application.
If U Get Errors U Will Learn
If U Don't Get Errors U Have Learnt
|
|
|
|
|
Mostafa Siraj wrote: I'm building a web application which has lots of users, each with lots of security rules. what is better???
1- to make a table for users and another table for permissions. and insure by coding(in ASP.NET for example) the security
2- to create for each user in the system new user in the DBMS itself and assign the security from the database.
Number 2 is a bad idea because every time you create a user from your ASP.NET application you will have to supply the database with sufficient permission to perform that action. If your application is attacked, do you really want the attacker to have the ability to create users in the database?
Number 2 is also a bad idea from a performance perspective. It means you won't be able to take advantage of the pooling of connections in your ASP.NET application as each user will be using a different connection. If they all use the ASP.NET user connection then you get the advantages of connection pooling.
So, by a process of elimination the answer seems to be #1. However, you can implement some of this in SQL Server by using Stored procedures and passing in a user ID and constraining the data returned based also on the user.
|
|
|
|
|
|
The first is better. Easier to maintain and look at the reason Colin said for #2 in his reply.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all,
I'm currently doing a contract and supplier window form application.
I have this table (Contract) containing the following fields:
Contract_ID INT NOT NULL,
Vendor_ID INT NOT NULL,
DateStart datetime,
DateDue datetime,
PRIMARY KEY(Contract_ID),
FOREIGN KEY (Vendor_ID) REFERENCES Vendor(Vendor_ID)
I would like to do something like select contracts up for renewal in 3 months (my DateDue values range from 2004-04-16 to 2012-10-29).
I only know how to begin with the following:
SQL Select Statement:-
SELECT Contract_ID FROM Contracts WHERE DateDue... blahblahblah (can anyone guide me to continue?)
I am not sure that the above beginning statement is correct..
Any help is greatly appreciated. Thanks!
telly
|
|
|
|