Tags: clause, columns, database, exclude, excluding, field, fields, include, mysql, names, oracle, rest, select, specifying, sql, table
Excluding fields in Select
Hi, Is there a way in a Select Clause to exclude one field and include rest from a table that has say 50 columns, without specifying the field names. Also, if I have following declaration in by PL/SQL procedure
then if rcd 1 has one extra field, is there a way to assign all the fields of rcd1 to rcd2 or vice versa without individual field assignments. Assigning each individual field in this case and also identifying each field in Select seems to be too conventional.
Leave a comment...
- 10 Comments
- You could create a view excluding the one field you want
and use the view instead of the table 'rcd1'.#1; Fri, 22 Feb 2008 03:47:00 GMT
- And the problem with conventionality is? Let's face it, if everybody went around with three foot waxed mustachios and a lobster on a leash then we'd never be able to get a decent cup of coffee. Umm, maybe I need to think this through a bit more...
Anyway, my point is:
SELECT * FROM my_table is fine when we're doing a bit of QAD programming in SQL*Plus. But when we are writing real programs, intended for production, we should always spell out the actual columns we want. All of them. SELECT * FROM is (in the words of the Inestimable Mr Kyte) a bug waiting to happen.
Cheers, APC#2; Fri, 22 Feb 2008 03:48:00 GMT
- I am already doing this in couple of cases and was looking for another solution. Thanks for the suggestion though.#3; Fri, 22 Feb 2008 03:49:00 GMT
- You are always better off specifying the names of individual columns in the select list of a select statement.#4; Fri, 22 Feb 2008 03:50:00 GMT
- Yeah, I totally agree. Now I am wondering why Oracle has introduced regular expressions in higher versions where the same thing could be done with combination of translate and for loops. Also, what could be a benefit of Trim if the same could be achieved by using Ltrim and Rtrim together. May be I am missing something here.
Thanks,#5; Fri, 22 Feb 2008 03:51:00 GMT
There are several advantages of using regular expressions in Oracle. This articles highlights some of the features of regular expressions.#6; Fri, 22 Feb 2008 03:52:00 GMT
- 355099, I really appreciate your sincere help, my reply was related to Andrew's comment about it being conventional. May be I hurt his feelings and I apologize for it. I was simply trying to make a point that new things get introduced to make coding simpler and that is why I was asking if there was a way to do what I wanted to do instead of listing field names. I know that defining field names is better but I do know that select * would not create problem in my case. I would at this point end this discussion to avoid any ill feelings.#7; Fri, 22 Feb 2008 03:53:00 GMT
- Isn't anyone worried about offending the lobster ?#8; Fri, 22 Feb 2008 03:54:00 GMT
- "offending the lobster"? Is that the sort of activity that can make you go blind?#9; Fri, 22 Feb 2008 03:55:00 GMT
- Sorry I haven't got an up to date copy of Rogers Profanasaurus.#10; Fri, 22 Feb 2008 03:56:00 GMT