SQL database operations
-- Take MySQL as an Example
// Log onto mysql-u root-p // CREATE a DATABASE named test_lib create database test_lib // delete a DATABASE named test_lib drop database test_lib // select test_lib database use test_lib // add a table containing three columns) [Reference] (http://www.runoob.com/ SQL /sql-create-table.html) CREATE TABLE table1 (column_name1 data_type (size), column_name2 data_type (size), column_name3 data_type (size); // delete a table (TABLE) drop table table_name // ADD a COLUMN (header) alter table table_name add column column_name VARCHAR (45); // delete a column alter table table1 drop column column1; // Add a row (specify a column in two ways, or do not specify a column) insert into table_name (column1, column2, column3 ,...) VALUES ('value1', 'value2', 'value3 ',...); insert into table_name VALUES ('value1', 'value2', 'value3 ',...); // DELETE a row delete from table_name WHERE column5 = 'ccc '; // display all data of test_lib SECLET * FROM test_lib // view how many databaseshow databases; // view the number of tableshow tables in a database; // view the currently used database select database (); // view the database port show variables like 'Port '; // view the database Code show variables like 'character % '; // View All Database user Information select distinct concat ('user: ''', user, ''' @ ''', host, '''; ') as query from mysql. user; // view the permissions of a specific user: show grants for 'root' @ 'localhost'; // view the current number of connections in the database. The number of concurrent connections is show status like 'threads % '; // view the data file storage path show variables like '% datadir % ';