1.
What Is Maximum Size Of Table In PostgreSQL?
1.
The PostgreSQL Has Maximum Size of Table Is 32TB.
2. How To Rename A Table In PostgreSQL
1. Alter Table Events Rename To Events_Backup;
3.
How To Truncate A Table In PostgreSQL
1.
Truncate My_Table
2.
Truncate My_Table Restart Identity
4.
How To Duplicate A Table In PostgreSQL
1.
Create Table Dupe_Users As (Select * From Users);
2.
Create Table Dupe_Users As (Select * From Users) With No Data; (--
The `With No Data` Here Means Structure Only, No Actual Rows)
5.
How To Add A Column In PostgreSQL
1.
Alter Table Users Add Column Created_At Timestamp Without Time
Zone;
2.
Alter Table Users Add Column Bio Character Varying Not Null;
3.
Alter Table Users Add Column Active Boolean Default True;
6. How To Drop A Column In PostgreSQL
1. Alter Table Users Drop Column Created_At;
7.
How To Rename A Column In PostgreSQL
1.
Alter Table Users Rename Column Registered_At To Created_At;
8. How To Add A Default Value To A Column In PostgreSQL
1.
Alter Table Orders Alter Column Total_Cents Set Default 0; (-- Example:
Orders Have A Default Total Of 0 Cents)
2. Alter Table Items Alter Column Available Set Default True; (-- Example:
Items Are Available By Default)
9.
How To Remove A Default Value From A Column In PostgreSQL
1.
Alter Table Orders Alter Column Total_Cents Drop Default;
10.
How To Add A Not Null Constraint In PostgreSQL
1.
Alter Table Users Alter Column Email Set Not Null;
11. How To Remove A Not Null Constraint In PostgreSQL
1. Alter Table Users Alter Column Email Drop Not Null;
12.
How To Create An Index In PostgreSQL
1.
Create Index Concurrently "Index_Created_At_On_Users" On
Users Using Btree (Created_At);
2.
Create Index Concurrently
"Index_User_Id_And_Time_On_Events" On Events Using Btree (User_Id,
Time);
3.
Create Unique Index Concurrently
"Index_Stripe_Event_Id_On_Stripe_Events"On Stripe_Events Using
Btree(Stripe_Event_Id);
4.
Create Index Concurrently "Index_Active_Users" On Users
Using Btree(Created_At) Where Active Is True;
5.
Create Unique Index Concurrently
"Index_Active_Credit_Cards" On Credit_Cards Using Btree(User_Id)
Where Active Is True;
13. How To Drop An Index In PostgreSQL
1. Drop Index Index_Created_At_On_Users;
No comments:
Post a Comment
It’s all about friendly conversation here at small review :) I’d love to be hear your thoughts!
Be sure to check back again because I do make every effort to reply to your comments here.