Suppose, we want to change the name of the column technologies to technology. Now, in case if we wish to change the name of the column then we can use the format 2 queries of alter table for fulfilling our purpose.\ Hence, our primary key constraint is added successfully. To check the keys lets describe the educba table using the command: Now, we will add a new primary key constraint on the tables id and technologies using the following alter table command –ĪLTER TABLE educba ADD CONSTRAINT tech_pkey PRIMARY KEY (id, technologies) Now, to drop the primary constraint educba_pkey, we can use the alter command in the following way –ĪLTER TABLE educba DROP CONSTRAINT educba_pkey įiring which gives the output as follows – Let us begin by creating a new table named educba which will store the data related to the corporation after checking all the present tables in our current db by using \dt command –Ĭheck whether the table is created by \dt command that gives output –įor describing the educba table, we can use the below command: The constraint which can be added should be mentioned in the following way – ActionOnTable – It can be any of the following actions you wish to perform on the target table –Īdd, drop and modify columns and their datatype, add or remove the constraints and rules and properties like replicas, primary and foreign constraints, enabling and disabling the triggers on the table, set OIDS and clusters, inheriting and not inheriting the parent properties, and resettable properties.tableName – Name of the table which you want to alter or modify.Hadoop, Data Science, Statistics
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |