The basic operations of the database include: 1. Basic operations of the database, creating a database, viewing all information in the database, modifying the database encoding set, and removing the database; 2. Basic operations of the table, creating tables, viewing table information, and modifying Field attributes, remove tables; 3. Basic operations of fields, add fields.
The basic operations of the database are:
1: Basic operations of the library
Prerequisite: Connect to the database
1. Add and create the database
Use the default encoding set
create database db1; # db1为数据库名
Customize the encoding set
create database db1 charset="gbk";
2. Check and view All database information
View all databases: show databases;
Detailed information: show create database db1;
3. Change, modify the database encoding set
alter database db1 charset="utf8"
4. Delete and remove the database
drop database db1;
2: Basic operations of the table
Prerequisite: Create a table under a specific database
Enter Specified database: use db1
Determine the currently used database: select database();
1. Add, create table (field 1, type,..., field n type)
create table t1(name char,age int);
2. Check and view table information
View all databases: show tables;
Detailed information: show create table t1;
Table field structure information: desc t1;
3. Change, modify field attributes
alter table t1 modify name char(20);
Modify field name
alter table t1 change name usr char(16);
Modify table name
alter table t1 rename t2;
4. Delete, remove table
drop table t1;
3: Basic operations of fields
Prerequisite: Know which table is being operated on
1. Add, add fields
insert into t1(usr,age) values ("aa",18),("bb",8);
2.Check
select * from t1;
3.Change
update t1 set age=28 where usr="aa";
4.Delete
delete from t1 where age>8;
Related learning recommendations:mysql video tutorial
The above is the detailed content of What are the basic database operations?. For more information, please follow other related articles on the PHP Chinese website!