CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: Why does the following command give a compilation error?
DROP TABLE &TABLE_NAME;

Answer: Variable names should start with an alphabet. Here the table name starts with an '&' symbol.



Category SQL Interview Questions & Answers - Exam Mode / Learning Mode
Rating (1.0) By 604 users
Added on 10/12/2009
Views 16470
Rate it!
Question: Why does the following command give a compilation error?
DROP TABLE &TABLE_NAME;

Answer:

Variable names should start with an alphabet. Here the table name starts with an '&' symbol. Source: CoolInterview.com


Any table name must start with alphabet. Table names starting with special characters are considered to be invalid hence give error. Source: CoolInterview.com

Answered by: Uday | Date: | Contact Uday Contact Uday

Hi All,

I never seen any error if i use '&' infront of a table name. In iSQL plus it will shows another window and we can put n number of table name.

Kindly clarify me Source: CoolInterview.com

Answered by: Binoj | Date: | Contact Binoj Contact Binoj

The command wil not give any compilation error.rather it asks for entering the value for the table name. I truly agree with the statement given by Binoj Source: CoolInterview.com

Answered by: Seema Mahato | Date: | Contact Seema Mahato Contact Seema Mahato

It wont give any compilation errors...
Result is given below.
SQL> DROP TABLE &TABLE_NAME;
Enter value for table_name:

'& is used to declare variables in SQL PLUS and iSQL PLUS.... Source: CoolInterview.com

Answered by: LPet | Date: 9/12/2008 | Contact LPet Contact LPet

It will not give any error ,It will ask the table name to drop that table,i executed this query in sql+
SQL> DROP TABLE &TABLE_NAME;
Enter value for table_name: student
old 1: DROP TABLE &TABLE_NAME
new 1: DROP TABLE student

Table dropped.
i was given the table name as student. student table was dropped. Source: CoolInterview.com

Answered by: shankarreddy | Date: 1/30/2009 | Contact shankarreddy Contact shankarreddy

Any table name must start with alphabet. Table names starting with special characters are considered to be invalid hence give error.
This symbol is used for getting input in the insert DML command. This Wrong in this Query...
Source: CoolInterview.com

Answered by: hari | Date: 2/23/2009 | Contact hari Contact hari

i thing that
drop table <table name > this is command Source: CoolInterview.com

Answered by: manpreet | Date: 5/27/2009 | Contact manpreet Contact manpreet

Hi All,

If you start the table name in special character it will shows an error. Source: CoolInterview.com

Answered by: Sathish S | Date: 10/13/2009 | Contact Sathish S Contact Sathish S

it will give error like :-
Incorrect syntax near '&'. Source: CoolInterview.com

Answered by: Satish Rathore | Date: 10/26/2009 | Contact Satish Rathore Contact Satish Rathore

Yes the query wil give the below error:-
Invalid Table Name.
Reason:-Table Name should start with alphabets. Source: CoolInterview.com

Answered by: kultar kaur | Date: 11/9/2009 | Contact kultar kaur Contact kultar kaur

I have tested the above sql command in both 9i and 10g

SQL> create table temp as select * from emp;

Table created.

SQL> commit;

Commit complete.

SQL> drop table &table_name;
Enter value for table_name: temp
old 1: drop table &table_name
new 1: drop table temp

Table dropped. Source: CoolInterview.com

Answered by: Raman | Date: 1/5/2010 | Contact Raman Contact Raman

it will give error like
table or view does not exist.
because drop table &username;
and gives exist table so table is droped. Source: CoolInterview.com

Answered by: Satyandera | Date: 1/30/2010 | Contact Satyandera Contact Satyandera

It will not give any error. Rather it will ask for a table name and when given it will drop the table if exists or give any error depending upon any constraint on the table Source: CoolInterview.com

Answered by: Jaydeep | Date: 2/13/2010 | Contact Jaydeep Contact Jaydeep

it doesn't give an error instead of that it'll ask u for the values and then drop the table.logically if we can't create a table which has name "&table_name"(tablename starts with speacial character) then how u will drop it.the syntax is like ...drop table &"tablename",here "&" is different and "tablename" is different. Source: CoolInterview.com

Answered by: iqubal | Date: 2/22/2010 | Contact iqubal Contact iqubal

SQL> DROP TABLE &emp;

This is d output

Enter value for table_name:emp
old 1: DROP TABLE &emp
new 1: DROP TABLE emp
Table dropped

in d same way we can drop view ie
drop view &viewname;
any object is dropd out Source: CoolInterview.com

Answered by: Nikez | Date: 2/26/2010 | Contact Nikez Contact Nikez

It will not give any error. Rather it will ask for a table name and when given it will drop the table if exists or give any error depending upon any constraint on the table




SQL> drop table &ss;
Enter value for ss: 1
old 1: drop table &ss
new 1: drop table 1
drop table 1
*
ERROR at line 1:
ORA-00903: invalid table name


SQL> /
Enter value for ss: ss
old 1: drop table &ss
new 1: drop table ss

Table dropped. Source: CoolInterview.com

Answered by: sriiramulu | Date: 3/5/2010 | Contact sriiramulu Contact sriiramulu

the errror is more likely due to the version of the SQL.
some compiler asks fof the table name and the other gives the error Source: CoolInterview.com

Answered by: manu | Date: 3/24/2010 | Contact manu Contact manu

In my understanding both the comments, whether it will give any error or not is DB specific and interviewer is not interested in knowing this part. If we assume that there is not syntax error, then drop table command will give you error if table drop violating some referential integrity constraint. Source: CoolInterview.com

Answered by: Rupesh Kumar | Date: 4/6/2010 | Contact Rupesh Kumar Contact Rupesh Kumar

As in SQL, & is used to get the value here when we execute this statement it will ask the table name that you want to drop Source: CoolInterview.com

Answered by: Padmanaban | Date: 4/12/2010 | Contact Padmanaban Contact Padmanaban

no body is providing the correct solution Source: CoolInterview.com

Answered by: vishalbabu | Date: 4/14/2010 | Contact vishalbabu Contact vishalbabu

There is no error in the statement. '&' symbol is used to get the value at run time. So when you give query "DROP TABLE &TABLE_NAME;", it asks you for table name at run time. If you give correct name, table will be dropped successfully. Source: CoolInterview.com

Answered by: umesh vats | Date: 4/16/2010 | Contact umesh vats Contact umesh vats

hi,
the above sql statement will not give any error,rather it asks for table name to be dropped.
i executed and checked that specified table will be dropped Source: CoolInterview.com

Answered by: tulasi | Date: 4/21/2010 | Contact tulasi Contact tulasi

THE STATEMENT WORKS PROPERLY BUT ONLY THE MISTAKE IS THAT WHEN U ENTER THE NAME FOR THE TABLE YOU SHOULD NOT USE SEMICOLON AGAIN ELSE IT WILL SHOW ERROR Source: CoolInterview.com

Answered by: AMIR | Date: 4/27/2010 | Contact AMIR Contact AMIR

this sql statement will not give any error. but table name should start with alphabets not special a characters. Source: CoolInterview.com

Answered by: dasteswarudu | Date: 5/2/2010 | Contact dasteswarudu Contact dasteswarudu

This statement giving error because table name never start with special symbol if we use following command then no error

DROP TABLE <TABLE NAME>; Source: CoolInterview.com

Answered by: Anil Kundlik | Date: 5/10/2010 | Contact Anil Kundlik Contact Anil Kundlik

drop table &table_name;
this is working (drop the table)
but
delete table &table_name;
not working this give error. Source: CoolInterview.com

Answered by: babu | Date: 5/20/2010 | Contact babu Contact babu

i have done it,,, here table_name that has been used is a variable name that will be asked by user which he want to drop.....
there will not be any error Source: CoolInterview.com

Answered by: vikash | Date: 5/20/2010 | Contact vikash Contact vikash

i do not see any error in this statement..when we execute this statement in sql *plus it will show another window to input the table name.it runs successfully Source: CoolInterview.com

Answered by: shailesh | Date: 6/15/2010 | Contact shailesh Contact shailesh

drop table &<TABLE NAME>
IF u give this command tosql server it will asks user which table u want to drop .ok
"&" symbol only ued for asking the values to user Source: CoolInterview.com

Answered by: ramesh.b | Date: 8/14/2010 | Contact ramesh.b Contact ramesh.b

will get Incorrect syntax near '&'. Source: CoolInterview.com

Answered by: s | Date: 8/18/2010 | Contact s Contact s

No compilation error,It will ask the table name to drop that table,i executed this query in sql
SQL> DROP TABLE &TABLE_NAME;
Enter value for table_name: engineer
old 1: DROP TABLE &TABLE_NAME
new 1: DROP TABLE engineer

Table dropped.

Source: CoolInterview.com

Answered by: manoj | Date: 9/4/2010 | Contact manoj Contact manoj


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
View Answer
What is the use of the DROP option in the ALTER TABLE command?
View Answer
What is the value of comm and sal after executing the following query if the initial value of ?sal? is 10000
UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;
View Answer
What is the use of DESC in SQL?
View Answer
What is the use of CASCADE CONSTRAINTS?
View Answer
Which function is used to find the largest integer less than or equal to a specific value?
View Answer
What is the output of the following query
SELECT TRUNC(1234.5678,-2) FROM DUAL;
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All SQL Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.625 Seconds