SQL database operations

Source: Internet
Author: User

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 % ';

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.