Database बनाना
CREATE DATABASE server पर एक नया, separate database बनाता है।
In this page:
Syntax
CREATE DATABASE database_name;
Database बनाना
CREATE DATABASE name template1 template से एक database बनाता है। Options में OWNER, ENCODING, और TEMPLATE शामिल हैं।
\c name या psql -d name से इससे connect करें। DROP DATABASE इसे remove करता है, और आप जिस database से connected हैं उसे drop नहीं कर सकते।
हर database की अपनी schemas और tables हैं।
Note:
Shell से आप createdb name भी चला सकते हैं।
उदाहरण: Creating database
postgres=# CREATE DATABASE shop OWNER appuser ENCODING 'UTF8';
CREATE DATABASE
postgres=# \c shop
You are now connected to database "shop" as user "postgres".
shop=# SELECT current_database();
current_database
------------------
shop
(1 row)
postgres=# DROP DATABASE shop;
DROP DATABASE
⚠️ Run this in your own terminal or Node.js environment.
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- वह database drop करने की कोशिश करना जिससे आप connected हैं
- यह भूल जाना कि databases एक-दूसरे से isolated हैं
- uppercase names इस्तेमाल करना जिन्हें फिर quotes चाहिए
चैप्टर सारांश
- CREATE DATABASE एक database बनाता है
- \c इससे connect करता है
- DROP DATABASE इसे remove करता है
- Databases एक-दूसरे से isolated हैं
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: