Mysql Flashcards
CHAR datatype
1) fixed length
2) given length of the string less than given fixed length ->length = fixed length
Add primary key to a relation
ALTER TABLE tablename ADD PRIMARY KEY
Add an attribute to an existing table
ALTER TABLE table_name ADD attribute name DATATYPE;
Modify datatype of an attribute
ALTER TABLE table_name MODIFY attribute DATATYPE
Modify constraint of an attribute
ALTER TABLE table_name MODIFY attribute DATATYPE NOT NULL;
Remove an attribute
ALTER TABLE table_name DROP attribute
Remove primary key from the table
ALTER TABLE table_name DROP PRIMARY KEY;
drop a table
DROP TABLE table_name;
drop a database
DROP DATABASE database_name;
Renaming of columns
SELECT EName as Name FROM EMPLOYEE;
Distinct Clause
SELECT DISTINCT DeptId FROM EMPLOYEE;
Data Updation
tax:
UPDATE table_name
SET attribute1 = value1, attribute2 = value2, …
WHERE condition;