पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
SQL का NOT BETWEEN keyword क्या करता है?
What does the SQL keyword NOT BETWEEN do?
Aयह देखता है कि मान किसी तय सीमा के भीतर है या नहींIt checks if a value falls within a specified range
Bयह देखता है कि मान किसी तय सीमा के बाहर हैIt checks if a value does not fall within a specified range
Cयह मान की तुलना परिणाम-समुच्चय या subquery के किसी एक मान से करता हैIt compares a value to any value in a result set or subquery
Dयह मान की तुलना परिणाम-समुच्चय या subquery के हर मान से करता हैIt compares a value to every value in a result set or subquery
सही उत्तर / Answer: (B)
हल / Solution
BETWEEN दोनों सिरों को जोड़कर सीमा देखता है, इसलिए «10 AND 20» में 10 और 20 भी गिने जाते हैं। NOT BETWEEN उसका उलटा है — शर्त तब सच होती है जब मान उस सीमा से बाहर पड़े, यानी नीचे वाले सिरे से कम या ऊपर वाले से ज़्यादा हो। सीमा के भीतर होना BETWEEN का काम है। किसी एक मान से तुलना ANY करता है और हर मान से ALL, इसलिए अंतिम दो विकल्प यहाँ लागू ही नहीं होते।
BETWEEN tests a range with both ends included, so a filter written as 10 AND 20 also accepts 10 and 20 themselves. NOT BETWEEN is its opposite: the condition is true when the value lies outside that range, below the lower end or above the upper one. Falling inside the range is what BETWEEN reports. Comparing with one value is the work of ANY and with every value of ALL, so the last two choices do not apply.
प्रश्न 2उत्तर + हल
किसी तालिका के column का नाम बदलने के लिए SQL का कौन-सा खंड (clause) काम आता है?
Which SQL clause is used to rename a column in a table?
ARENAME COLUMN
BALTER COLUMN
CMODIFY COLUMN
DUPDATE COLUMN
सही उत्तर / Answer: (A)
हल / Solution
नाम बदलने का सीधा रूप है — ALTER TABLE के बाद RENAME COLUMN, पुराना नाम, TO, और नया नाम। ALTER COLUMN का काम column का प्रकार या उसकी null-छूट बदलना है, नाम नहीं। MODIFY COLUMN भी परिभाषा बदलता है, नाम वहीं का वहीं रहता है। UPDATE COLUMN जैसा कोई खंड SQL में नहीं है — UPDATE तो पंक्तियों के मान बदलती है, ढाँचे को छूती ही नहीं।
The direct form is ALTER TABLE, then RENAME COLUMN, the old name, the word TO, and the new name. ALTER COLUMN exists to change a column's type or its nullability, not its name. MODIFY COLUMN likewise redefines the column while the name stays as it was. There is no clause called UPDATE COLUMN in SQL, because UPDATE changes values inside rows and never touches the structure of a table.
प्रश्न 3उत्तर + हल
SQL की DROP VIEW कमांड क्या करती है?
What does the SQL command DROP VIEW do?
Aडेटाबेस से किसी तालिका को हटा देती हैDrops a table from the database
Bडेटाबेस से किसी index को हटा देती हैDeletes an index from the database
Cडेटाबेस से किसी view को हटा देती हैRemoves a view from the database
Dतालिका का ढाँचा रहने देकर उसके सारे रिकॉर्ड मिटा देती हैDeletes all records from a table without removing the table structure
सही उत्तर / Answer: (C)
हल / Solution
DROP VIEW डेटा शब्दकोश (data dictionary) से उस view की परिभाषा हटा देती है। view में पंक्तियाँ रखी ही नहीं होतीं, इसलिए मूल तालिकाओं का डेटा ज़रा भी नहीं जाता — बस वह नाम आगे पढ़ा नहीं जा सकेगा और उस पर टिकी query टूट जाएँगी। तालिका हटाने का काम DROP TABLE का है, index हटाने का DROP INDEX का, और ढाँचा रखकर सारी पंक्तियाँ मिटाने का TRUNCATE TABLE का।
DROP VIEW removes the definition of the view from the data dictionary. A view holds no rows of its own, so not a single row of the base tables is lost; what breaks is any query that referred to that name. Removing a table is the job of DROP TABLE, and an index is removed by DROP INDEX. Clearing every row while keeping the structure is done by TRUNCATE TABLE instead.
प्रश्न 4उत्तर + हल
यह जाँचने के लिए कि कोई मान दिए गए मानों के समुच्चय में मौजूद है या नहीं, SQL का कौन-सा keyword काम आता है?
Which SQL keyword is used to check if a value exists in a specified set of values?
AIN
BNOT IN
CEXISTS
DALL
सही उत्तर / Answer: (A)
हल / Solution
IN मान को एक सूची या subquery के मानों से मिलाता है, और किसी एक से बराबरी हो जाने पर शर्त सच हो जाती है। कई OR लिखने की जगह यह छोटा रास्ता है। NOT IN इसका उलटा है, इसलिए वह मौजूदगी नहीं, अनुपस्थिति बताता है। EXISTS मान देखता ही नहीं, वह सिर्फ़ पंक्ति लौटने की ख़बर देता है। और ALL तुलना संकारक के साथ लगकर हर मान पर शर्त पूरी होने की माँग करता है।
IN matches a value against a list or against the values returned by a subquery, and the condition is true as soon as one of them is equal. It is a short way of writing several OR comparisons. NOT IN is its opposite, so it reports absence rather than presence. EXISTS never looks at the values and only reports whether a row came back, and ALL requires the comparison to hold for every value.
प्रश्न 5उत्तर + हल
किसी तालिका पर विदेशी कुंजी (foreign key) का प्रतिबंध लगाने के लिए SQL का कौन-सा खंड (clause) काम आता है?
Which SQL clause is used to add a foreign key constraint to an existing table?
AADD FOREIGN KEY
BCREATE FOREIGN KEY
CDEFINE FOREIGN KEY
DSET FOREIGN KEY
सही उत्तर / Answer: (A)
हल / Solution
पहले से बनी तालिका पर कड़ी जोड़ने का रूप है — ALTER TABLE के बाद ADD FOREIGN KEY, कोष्ठक में अपना column, और फिर REFERENCES के साथ दूसरी तालिका तथा उसकी कुंजी। चाहें तो ADD CONSTRAINT से प्रतिबंध को नाम भी दे दें। बाक़ी तीनों रूप SQL में नहीं हैं। यही प्रतिबंध संदर्भात्मक अखंडता (referential integrity) लागू करता है, इसलिए इसे लगाते समय मौजूदा बेमेल मान पहले साफ़ करने पड़ते हैं।
On a table that already exists, the link is declared by writing ALTER TABLE, then ADD FOREIGN KEY with the local column in brackets, and then REFERENCES with the other table and its key. You may also name the constraint by using ADD CONSTRAINT first. The other three forms are not SQL at all. Because this clause enforces referential integrity, any existing unmatched values have to be cleaned up before it is accepted.
प्रश्न 6उत्तर + हल
SQL की CREATE SCHEMA कमांड क्या करती है?
What does the SQL command CREATE SCHEMA do?
Aकिसी मौजूदा डेटाबेस के सारे objects हटा देती हैRemoves all objects from an existing database
Bएक नई तालिका का ढाँचा तय करती हैDefines the structure of a new table
Cएक नामस्थान (namespace) बनाती है जिसके भीतर डेटाबेस के objects रहते हैंDefines a namespace in which database objects exist
Dकिसी मौजूदा तालिका में एक नई पंक्ति जोड़ती हैAdds a new row to an existing table
सही उत्तर / Answer: (C)
हल / Solution
मानक SQL में schema एक नामस्थान (namespace) है — तालिकाएँ, view, index और प्रतिबंध सब उसी के भीतर नाम पाते हैं। इससे एक ही डेटाबेस में दो विभाग अपनी-अपनी «employees» तालिका रख सकते हैं, क्योंकि पूरा नाम schema के साथ बनता है, और अधिकार भी schema पर एक साथ दिए जा सकते हैं। तालिका का ढाँचा CREATE TABLE तय करती है, पंक्ति INSERT जोड़ती है, और objects हटाना DROP का काम है।
In standard SQL a schema is a namespace: tables, views, indexes and constraints all take their names inside it. Two departments can therefore keep their own employees table in one database, because the full name includes the schema, and privileges can be granted on the schema as a whole. The structure of a table is defined by CREATE TABLE, a row is added by INSERT, and objects are taken away by DROP.
प्रश्न 7उत्तर + हल
SQL का NOT IN keyword क्या करता है?
What does the SQL keyword NOT IN do?
Aयह देखता है कि मान, दिए गए मानों के समुच्चय में मौजूद है या नहींIt checks if a value exists in a specified set of values
Bयह देखता है कि मान, दिए गए मानों के समुच्चय में मौजूद नहीं हैIt checks if a value does not exist in a specified set of values
Cयह देखता है कि मान किसी तय सीमा के भीतर है या नहींIt checks if a value falls within a specified range
Dयह देखता है कि मान किसी तय सीमा के बाहर है या नहींIt checks if a value does not fall within a specified range
सही उत्तर / Answer: (B)
हल / Solution
NOT IN, IN का उलटा है — शर्त तब सच होती है जब मान दी गई सूची या subquery के किसी भी मान से मेल न खाए। एक सावधानी याद रखिए: सूची में कहीं NULL पड़ा हो तो पूरी शर्त अज्ञात (unknown) हो जाती है और एक भी पंक्ति नहीं लौटती। सूची में मौजूद होना IN देखता है। सीमा के भीतर या बाहर होना BETWEEN और NOT BETWEEN का काम है।
NOT IN is the opposite of IN: the condition is true when the value matches none of the values in the given list or subquery. One trap is worth remembering. If the list contains a NULL, the whole condition becomes unknown and not a single row is returned, which is why a filter on nullable data is written carefully. Membership in a list is tested by IN, while a range is tested by BETWEEN or NOT BETWEEN.
प्रश्न 8उत्तर + हल
SQL की CREATE VIEW कमांड क्या करती है?
What does the SQL command CREATE VIEW do?
Aडेटाबेस में एक नई तालिका बनाती हैCreates a new table in the database
Bकिसी मौजूदा तालिका में नया column जोड़ती हैAdds a new column to an existing table
Cकिसी SELECT query के परिणाम पर आधारित एक आभासी तालिका (virtual table) बनाती हैDefines a virtual table based on the result of a SELECT query
Dकिसी तालिका के column का डेटा प्रकार बदलती हैModifies the data type of a column in a table
सही उत्तर / Answer: (C)
हल / Solution
CREATE VIEW किसी SELECT query को नाम दे देती है। उस नाम को तालिका की तरह पढ़ा जा सकता है, पर उसमें डेटा रखा नहीं जाता — मान हर बार मूल तालिकाओं से निकलते हैं, इसीलिए इसे आभासी तालिका (virtual table) कहते हैं। इससे जटिल query छिप जाती है और छात्र या उपयोगकर्ता को सिर्फ़ ज़रूरी column दिखाए जा सकते हैं। नई तालिका CREATE TABLE बनाती है, और column जोड़ना या उसका प्रकार बदलना ALTER TABLE का काम है।
CREATE VIEW gives a name to a stored SELECT query. That name can be read like a table, yet no rows are kept in it, because the values are produced from the base tables each time it is used. This is why it is called a virtual table. A view hides a complicated query and can expose only the columns a user should see. A real table comes from CREATE TABLE, while adding or retyping a column needs ALTER TABLE.
प्रश्न 9उत्तर + हल
यह जाँचने के लिए कि subquery से कोई पंक्ति लौटती है या नहीं, SQL का कौन-सा keyword काम आता है?
Which SQL keyword is used to check if a subquery returns any rows?
AALL
BANY
CEXISTS
DIN
सही उत्तर / Answer: (C)
हल / Solution
EXISTS सिर्फ़ यह देखता है कि subquery से एक भी पंक्ति लौटी या नहीं। पंक्ति मिली तो सच, न मिली तो झूठ — मान क्या हैं, इससे कोई मतलब नहीं। पहली पंक्ति मिलते ही जाँच रुक जाती है, इसलिए यह तेज़ भी रहता है। ALL और ANY मानों की तुलना तुलना संकारक के साथ करते हैं। IN देखता है कि मान सूची में है या नहीं, यानी वह भी मान से ही जुड़ा है।
EXISTS asks one thing only: did the subquery return even a single row? If a row came back the condition is true, and if none came back it is false, while the actual values are never examined. Checking can stop at the first matching row, which also makes it fast. ALL and ANY compare values along with a comparison operator. IN tests whether a value appears in a list, so it too depends on the values.
प्रश्न 10उत्तर + हल
किसी तालिका पर प्राथमिक कुंजी (primary key) का प्रतिबंध लगाने के लिए SQL का कौन-सा खंड (clause) काम आता है?
Which SQL clause is used to add a primary key constraint to an existing table?
AADD PRIMARY KEY
BCREATE PRIMARY KEY
CDEFINE PRIMARY KEY
DSET PRIMARY KEY
सही उत्तर / Answer: (A)
हल / Solution
पहले से बनी तालिका पर प्राथमिक कुंजी इस रूप में लगती है — ALTER TABLE के बाद ADD PRIMARY KEY और कोष्ठक में column का नाम। चाहें तो ADD CONSTRAINT के साथ प्रतिबंध को नाम भी दे सकते हैं। बाक़ी तीनों रूप SQL में मौजूद ही नहीं हैं। ध्यान रहे, प्राथमिक कुंजी वाला column न दोहराया जा सकता है और न null रह सकता है, इसलिए पहले से पड़ा दोहराव हटाना ज़रूरी होता है।
On a table that already exists, a primary key is added by writing ALTER TABLE, then ADD PRIMARY KEY, and the column name in brackets. You may also give the constraint a name by using ADD CONSTRAINT before it. The other three forms do not exist in SQL at all. Remember that a primary key column can hold neither duplicates nor nulls, so existing duplicate values must be cleaned up before the clause will succeed.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
SQL में > या < जैसे तुलना संकारक (comparison operator) के साथ कौन-सा keyword लगाकर यह देखा जाता है कि मान, subquery से लौटे मानों में से कम से कम किसी एक के साथ शर्त पूरी करता है?
In SQL, which keyword is used with a comparison operator such as > or < to test whether a value satisfies the comparison with at least one of the values returned by a subquery?
subquery के साथ ALL keyword की सही वाक्य-रचना कौन-सी है?
What is the correct syntax for using the ALL keyword with a subquery?
ASELECT * FROM Orders WHERE Quantity > ALL (SELECT Quantity FROM Products);
BSELECT * FROM Orders WHERE Quantity > ALL Products.Quantity;
CSELECT * FROM Orders WHERE Quantity ALL > (SELECT Quantity FROM Products);SELECT * FROM Orders WHERE Quantity > ALL FROM (SELECT Quantity FROM Products);
DSELECT * FROM Orders WHERE Quantity > ALL FROM (SELECT Quantity FROM Products);SELECT * FROM Orders WHERE Quantity ALL > (SELECT Quantity FROM Products);