Create a database
CREATE DATABASE [databasename];Show all tables in database
show tables ;To make a database your active database
USE [databasename];Create a table
CREATE TABLE [tablename] ( [col(1)title] [type] , [col(2)title] [type] ,...,[col(n)title] [type]) ;Insert data in to table
INSERT INTO [tablename] ( [col(1)title], [col(2)title],..., [col(n)title] ) VALUES ( [dataforcol(1)], [dataforcol(2)],..., [dataforcol(n)],);Shows the structure of the table
DESCRIBE [tablename];Show all data in table
SELECT * FROM [tablename];
Show specific data (x) in table
SELECT * FROM [tablename] WHERE [col_title] = "[x]";
Add a column (in front)
ALTER TABLE [tablename] ADD [col_title] [type] FIRST;Add a column (anywhere after col(N) )
ALTER TABLE [tablename] ADD [col_title] [type] AFTER [col(N)title];Delete a column
ALTER TABLE [tablename] DROP [col_title];Change column type
ALTER TABLE [tablename] MODIFY [col_title] [type];Change column name (and type)
ALTER TABLE [tablename] CHANGE [old_col_title] [new_col_title] [type];Delete data entry/row
DELETE from [tablename] WHERE [col_title] = '[element]';Delete all data in table
DELETE from [tablename];
No comments:
Post a Comment