In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Create a database
MariaDB [(none)]> CRRATE DATABASE test1; #Create a database named test1 MariaDB [(none)]> CRRATE DATABASE IF NOT EXISTS test2; #Create a database named test2 MariaDB [(none)]> SHOW ASES; #Show existing databases
2. Delete database
MariaDB [(none)]> DROP DATABASE test1; #delete database named test1 MariaDB [(none)]> DROP DATABASE IF EXISTS test1;
3. Create a table
Format: CREAT TABLE tb_name(col1, col2, col3,...);
MariaDB [(none)]> CREATE TABLE test2.teacher(Name CHAR(20) NOT NULL,Age TINYINT UNSIGNED,Gender CHAR(1) NOT NULL); #create table in test2 teacherMariaDB [(none)]> USE test2;MariaDB [(test2)]> CREATE TABLE student(Name CHAR(20) NOT NULL,Age TINYINT UNSIGNED,Gender CHAR(1) NOT NULL); #Another way to create a table studentMariaDB [(test2)]> SHOW TABLES FROM test2; #View tables in database test2
4. View table structure
MariaDB [(test2)]> DESCRIPTION student;MariaDB [(test2)]> DESC teacher; #DESCRIPTION can be abbreviated as DESC
5. Delete table
MariaDB [(test2)]> DROP TABLE teacher;MariaDB [(test2)]> DROP TABLE IF EXISTS teacher;
6. Amendment table
MariaDB [(test2)]> ALTER TABLE student ADD course VARCHAR(80); #add a field courseMariaDB [(test2)]> DESC student;MariaDB [(test2)]> ALTER TABLE student CHANGE Course VARCHAR(80) AFTER Name; #Change course to Course and put it after Name MariaDB [(test2)]> DESC student;
7. Insert data information
MariaDB [(test2)]> INSERT INTO student (Name,Gender) VALUE ('Tom','M'),('Jerry','F');MariaDB [(test2)]> SELECT * FROM student;MariaDB [(test2)]> INSERT INTO student VALUE ('Jack','Math',16,'M');
8. Modify and update data information
MariaDB [(test2)]> UPDATE student SET Course='Physics' WHERE Name='Tom'; #Insert PhysicsMariaDB [(test2)]> SELECT Name,Course From student WHERE Course ='Physics 'into the Course field of the row named Tom; #Select Name and CourseMariaDB [(test2)]> Delete From student Where Coures='Physics'; #Delete all rows where lessons are physical
9. Create and delete users
CREATE USER 'username'@'host' [IDENTIFIED BY 'password'];
DROP USER 'username'@'host';
MariaDB [(none)]> CREATE USER 'Lucy'@'localhost' INDENTIFIED BY '123456';MariaDB [(none)]> SHOW GRANTS FOR 'Lucy'@'localhost'; #View user's authorizations MariaDB [(none)]> CREATE USER 'Lily'@'192.168.1.50'MariaDB [(none)]> CREATE USER 'Bob'@'%' #where % is a wildcard, indicating any number of characters, underscore_indicates any single character
10. Authorization
GRANT pri1,pri2,pri3,... ON dbname.tbname TO 'username'@'host' [IDENTIFIED BY 'password'];
REVOKE pri1,pri2,pri3,... ON dbname.tbname FROM 'username'@'host';#Remove permissions
MariaDB [(none)]> GRANT ALL PRIVILEGES ON test2.* TO 'Lucy'@'%'; #Grant user 'Lucy'@'%' full permissions on all tables in test2 library MariaDB [(none)]> SHOW GRANTS FOR 'Lucy'@'%';
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.