hi
today i would like to write all SQL commands that mostly i am using in my analysis.
1- create database :
mysql> create database test_db;
2- enter on your database:
mysql> use test_db;
3- deleting all database:
mysql> drop database test_db ;
4- Create table :
mysql> create table login ( User_Id varchar(18) , Time_Spent int , hits int , gender char(1));
5- showing the name of all tables in the database :
mysql > show tables;
6-deleting table :
mysql> drop log_table;
7- show the structure of tables :
mysql> describe table_name ;
8- changing the structure of tables (adding/ deleting columns):
mysql> alter table table_name DROP column_Name ;
or
mysql> alter table table_name add Reg_No varchar(18);
9- Inserting rows into table :
mysql> Insert into table_name table_column_name values ();
10- loading data from .txt file into sql table:
mysql> load data local infile "h:/pp.txt" into table table_name fields terminated by "," ;
11- make one table with joining two other table :
mysql> create tabel NV as (select T.User_Id, S.Sname, S.Reg_No from Tool as T, Sol as S where T.User_Id=S.User_Name) ;
12- Export data from mysql to .txt file :
mysql> select * into outfile "h:/u.txt" fields terminated by "," from NV where gender="f" ;
13- showing favorite numbers of lines from table in SQL :
mysql> select * from table_name limit 100 ;
14- Update data :
mysql> update table_name set age=age+1 ;
15- delete data from table :
mysql > delete from table_name where state="ky" ;
16- create another table based on one tables contents sum :
mysql> select customer_Id, count(distinct transactions) as T, sum(quantity) as items_bought , sum (amount) as spendings from table1 group by customer_Id order by spending desc;
today i would like to write all SQL commands that mostly i am using in my analysis.
1- create database :
mysql> create database test_db;
2- enter on your database:
mysql> use test_db;
3- deleting all database:
mysql> drop database test_db ;
4- Create table :
mysql> create table login ( User_Id varchar(18) , Time_Spent int , hits int , gender char(1));
5- showing the name of all tables in the database :
mysql > show tables;
6-deleting table :
mysql> drop log_table;
7- show the structure of tables :
mysql> describe table_name ;
8- changing the structure of tables (adding/ deleting columns):
mysql> alter table table_name DROP column_Name ;
or
mysql> alter table table_name add Reg_No varchar(18);
9- Inserting rows into table :
mysql> Insert into table_name table_column_name values ();
10- loading data from .txt file into sql table:
mysql> load data local infile "h:/pp.txt" into table table_name fields terminated by "," ;
11- make one table with joining two other table :
mysql> create tabel NV as (select T.User_Id, S.Sname, S.Reg_No from Tool as T, Sol as S where T.User_Id=S.User_Name) ;
12- Export data from mysql to .txt file :
mysql> select * into outfile "h:/u.txt" fields terminated by "," from NV where gender="f" ;
13- showing favorite numbers of lines from table in SQL :
mysql> select * from table_name limit 100 ;
14- Update data :
mysql> update table_name set age=age+1 ;
15- delete data from table :
mysql > delete from table_name where state="ky" ;
16- create another table based on one tables contents sum :
mysql> select customer_Id, count(distinct transactions) as T, sum(quantity) as items_bought , sum (amount) as spendings from table1 group by customer_Id order by spending desc;
No comments:
Post a Comment