Altering a Schema in SQL-99 in Hindi
Altering a Schema in SQL-99 in Hindi | SQL-99 Schema Modification Tutorial
Altering a Schema in SQL-99 in Hindi
परिचय (Introduction – Altering a Schema in SQL-99 in Hindi)
जब हम एक database के अंदर schema को बदलना चाहते हैं — जैसे नाम बदलना, owner बदलना, या अंदर के objects को दूसरे schema में ले जाना — तो यह काम “altering a schema in SQL-99” कहलाता है। इस लेख में हम इस topic को बहुत ही सरल भाषा में विस्तार से समझेंगे ताकि आप SQL-99 में schema modification अच्छे से सीख सकें।
SQL-99 में Schema का मतलब क्या है? (What is Schema in SQL-99 in Hindi)
SQL-99 मानक में, एक schema एक नामित समूह (named collection) है जिसमें tables, views, domains, constraints आदि शामिल होते हैं। :contentReference[oaicite:0]{index=0} Schema एक catalog के अंदर अस्तित्व में होता है, और schema का नाम उस catalog के अंदर unique होना चाहिए। :contentReference[oaicite:1]{index=1} इस तरह यह data को logical grouping प्रदान करता है और access control को भी सहायता करता है।
SQL-99 में Schema को बदलने की सीमा (Limitations of Altering a Schema in SQL-99 in Hindi)
SQL-99 standard खुद “ALTER SCHEMA” जैसा एक direct command नहीं देता जो schema का नाम या owner बदल सके। :contentReference[oaicite:2]{index=2} बल्कि schema में शामिल objects को CREATE / DROP / ALTER statements के माध्यम से बदला जाता है। :contentReference[oaicite:3]{index=3} उदाहरण के लिए, table को drop करना, table में column जोड़ना या हटाना — ये सभी operations schema के अंदर होते हैं। :contentReference[oaicite:4]{index=4} इसके कारण “altering a schema in SQL-99” विषय में हमें object-level changes पर ध्यान देना पड़ता है न कि schema-level rename जैसा काम।
Schema में objects को modify करने की commands (Commands to Modify Objects inside Schema in Hindi)
-
ALTER TABLE – table में new column जोड़ना, column drop करना, default value बदलना आदि।
उदाहरण:
ALTER TABLE MySchema.MyTable ADD new_column VARCHAR(100); -
DROP TABLE – यदि वह table अब आवश्यक न हो, तो schema से table को हटाना।
उदाहरण:
DROP TABLE MySchema.OldTable; -
ALTER CONSTRAINT / DROP CONSTRAINT – किसी table या schema object पर लगे constraint जैसे foreign key, primary key को हटाना या बदलना।
उदाहरण:
ALTER TABLE MySchema.MyTable DROP CONSTRAINT fk_constraint_name; - CREATE / DROP DOMAIN, CREATE / DROP VIEW आदि – यदि आपको view, domain आदि schema level object बदलने हों तो CREATE या DROP का उपयोग करना।
SQL-Server & PostgreSQL में ALTER SCHEMA व्यवहार (Behavior in SQL Server & PostgreSQL in Hindi)
यद्यपि SQL-99 में direct ALTER SCHEMA नहीं है, आधुनिक RDBMS systems (जैसे SQL Server, PostgreSQL) ने अपने extensions दिए हैं। उदाहरण के लिए, SQL Server में आप किसी object को एक schema से दूसरे schema में स्थानांतरित कर सकते हैं। :contentReference[oaicite:5]{index=5} PostgreSQL में आप schema का नाम बदल सकते हैं या owner बदल सकते हैं। :contentReference[oaicite:6]{index=6}
SQL Server में ALTER SCHEMA उदाहरण (SQL Server Example in Hindi)
SQL Server में schema-level rename नहीं बल्कि object transfer supported है। :contentReference[oaicite:7]{index=7}
उदाहरण: यदि हमें dbo.GeekTable को दूसरे schema “geek” में ले जाना है —
ALTER SCHEMA geek TRANSFER OBJECT::dbo.GeekTable;
इसके बाद उन functions/views/triggers को update करना होगा जिनमें इस table का full qualified name hard-coded हो।
PostgreSQL में ALTER SCHEMA उदाहरण (PostgreSQL Example in Hindi)
PostgreSQL में आप schema का नाम बदल सकते हैं या owner को बदल सकते हैं (SQL-99 standard में यह नहीं था)। :contentReference[oaicite:8]{index=8}
उदाहरण:
ALTER SCHEMA old_schema_name RENAME TO new_schema_name;
या
ALTER SCHEMA schema_name OWNER TO new_owner;
लेकिन PostgreSQL में यह SQL standard का हिस्सा नहीं है — यह proprietary extension है। :contentReference[oaicite:9]{index=9}
Objects ट्रांसफ़र करना (Transferring Objects in SQL Server — related to altering a schema in SQL-99 in Hindi)
यदि कोई table, view या function एक schema से दूसरे schema में जाना हो, SQL Server में ALTER SCHEMA TRANSFER command इस्तेमाल होती है। :contentReference[oaicite:10]{index=10} ध्यान दें कि यह केवल same database के अंदर काम करती है। :contentReference[oaicite:11]{index=11}
Why SQL-99 में direct ALTER SCHEMA नहीं है? (Why direct ALTER SCHEMA is not in SQL-99 in Hindi)
SQL-99 standard को design करते वक्त schema-level rename/change operations को include नहीं किया गया था, शायद क्योंकि उन operations के semantics DBMS-specific हो सकते हैं। इसलिए standard ने object-level modification commands (ALTER TABLE, DROP, CREATE) पर जोर दिया। :contentReference[oaicite:12]{index=12}
Comparison Table: SQL-99 vs Modern RDBMS (for altering schema in SQL-99 in Hindi)
| Feature | SQL-99 (Standard) | Modern RDBMS (SQL Server / PostgreSQL) |
|---|---|---|
| Direct ALTER SCHEMA | नहीं उपलब्ध | Schema rename / owner change / object transfer supported |
| Object-level modify | Supported (ALTER TABLE, DROP, CREATE, etc.) | Supported + ALTER SCHEMA extensions |
| Transfer between schemas | No standard command | SQL Server: ALTER SCHEMA TRANSFER; PostgreSQL: rename/ownership change |
Best Practices और सावधानियाँ (Best Practices & Precautions in Hindi)
- जब आप object को एक schema से दूसरे में ले जाते हैं, तो सभी dependencies (views, triggers, stored procedures) को update करना न भूलें।
- permissions (privileges) reset हो सकते हैं — कुछ systems में transfer के बाद related grants हट जाते हैं।
- यदि आप PostgreSQL में schema rename कर रहे हैं, तो ensure करें कि नए नाम system schema prefix (जैसे pg_) से शुरू न हो। :contentReference[oaicite:13]{index=13}
- large schema changes को transaction में करना बेहतर है ताकि failure की स्थिति में rollback संभव हो।
निष्कर्ष (Conclusion – altering a schema in SQL-99 in Hindi)
“Altering a schema in SQL-99” चीज़ सीधे standard में defined नहीं है, बल्कि schema के अंदर objects को ALTER / DROP / CREATE commands से ही बदला जाता है। आधुनिक RDBMS systems ने schema-level operations के लिए extensions दिए हैं जैसे SQL Server में object transfer और PostgreSQL में rename / owner change। यदि आप SQL-99 के context में काम कर रहे हैं, तो focus हमेशा object-level modifications पर ही रखना होगा।
External Resource: यदि आप PostgreSQL में ALTER SCHEMA syntax जानना चाहते हैं, तो PostgreSQL की official documentation देख सकते हैं। (उदाहरण: PostgreSQL ALTER SCHEMA documentation)
FAQs
ALTER SCHEMA old_name RENAME TO new_name; का उपयोग करके schema का नाम बदल सकते हैं।
यह feature SQL-99 standard का हिस्सा नहीं है बल्कि DBMS extension है।
ALTER SCHEMA sales TRANSFER OBJECT::dbo.Product;
यह command Product table को dbo schema से sales schema में move कर देती है।
यह केवल same database के अंदर ही काम करती है।
- ALTER TABLE – Table में columns जोड़ना या हटाना।
- DROP TABLE – Unused table हटाना।
- ALTER CONSTRAINT – Constraints बदलना या हटाना।
- CREATE / DROP VIEW – Schema के अंदर views modify करना।
- Schema का नाम बदलना (Rename Schema)
- Schema के owner को बदलना (Change Owner)
ALTER SCHEMA finance RENAME TO accounts;
या
ALTER SCHEMA accounts OWNER TO manager;
यह feature PostgreSQL का extension है जो SQL-99 में उपलब्ध नहीं था।