SSC IMD SA 2017 – Question 176

Question:

Which of the following statements is true?

निम्न में से कौन-सा कथन सत्य है?

Options:

  • The basic data type char(n) is a fixed-length character string and varchar(n) is an equal-length character string
  • The basic data type char(n) is a uniform-length character string and varchar(n) is a variable-length character string
  • The basic data type char(n) is a fixed-length character string and varchar(n) is a variable-length character string
  • The basic data type char(n) is a variable-length character string and varchar(n) is an equal-length character string
  • मूल डेटा टाइप char (n) एक निश्चित लंबाई कैरेक्टर स्ट्रिंंग और varchar (n) बराबर लम्बाई के कैरेक्टर है।
  • मूल डेटा प्रकार char (n) एक समान लंबाई कैरेक्टर स्ट्रिंंग और varchar (n) चर लंबाई कैरेक्टर है।
  • मूल डेटा प्रकार char (n) एक निश्चित लंबाई कैरेक्टर स्ट्रिंंग और varchar (n) चर लंबाई कैरेक्टर है।
  • मूल डेटा प्रकार char (n) एक चर लंबाई कैरेक्टर स्ट्रिंंग और varchar (n) बराबर लम्बाई कैरेक्टर है।

Correct Answer: c)

Explanation:

Detailed Explanation:

The correct answer is c) char(n) is a fixed-length character string and varchar(n) is a variable-length character string (मूल डेटा प्रकार char (n) एक निश्चित लंबाई कैरेक्टर स्ट्रिंग और varchar (n) चर लंबाई कैरेक्टर है।).

In Relational Database Management Systems (SQL standard), character string data types are defined as follows:

  • CHAR(n) (Fixed-Length): Represents a fixed-length string of size $n$. If a string of fewer than $n$ characters is inserted, the RDBMS automatically right-pads the remaining space with blank characters (spaces) up to length $n$. Memory is pre-allocated uniformly.
  • VARCHAR(n) (Variable-Length): Represents a variable-length string with a maximum capacity of $n$ characters. It allocates only the actual number of characters stored plus 1 or 2 prefix bytes used to record the string’s length, thus optimizing disk storage and memory usage.

Therefore, statement c accurately distinguishes fixed-length char(n) from variable-length varchar(n).

विस्तृत व्याख्या:

सही उत्तर c) मूल डेटा प्रकार char (n) एक निश्चित लंबाई कैरेक्टर स्ट्रिंग और varchar (n) चर लंबाई कैरेक्टर है। है।

एसक्यूएल (SQL) और रिलेशनल डेटाबेस में कैरेक्टर डेटा प्रकारों की कार्यप्रणाली:

  • CHAR(n) (Fixed Length / निश्चित लंबाई): यह $n$ वर्णों की निश्चित लंबाई वाली कैरेक्टर स्ट्रिंग है। यदि इसमें $n$ से कम वर्ण संग्रहीत किए जाते हैं, तो डेटाबेस शेष स्थान को रिक्त स्थानों (Spaces) से भर देता है।
  • VARCHAR(n) (Variable Length / चर लंबाई): यह परिवर्तनीय लंबाई वाली स्ट्रिंग है जिसकी अधिकतम सीमा $n$ वर्ण होती है। इसमें केवल उतने ही वर्णों का स्थान लिया जाता है जितने प्रविष्ट किए गए हैं, जिससे मेमोरी और डिस्क स्पेस की बचत होती है।

अतः CHAR(n) एक निश्चित लंबाई और VARCHAR(n) एक चर (परिवर्तनीय) लंबाई वाली स्ट्रिंग है।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top