Mysql and oracle Database basic operations, mysqloracle
This is the command and statement that you collect online and use at ordinary times (suitable for beginners ).
I. mysql (note that there are spaces between commands)
Run the cmd command to start/Close the database: net start/stop mysql
Open mysql and enter the command line: mysql-u + username-p + Password
First, create a simple user table in the test database:
Use test; // use the test database
Drop table if exists user; // Delete the user table if the user table exists.
Create table user (
Uid int primary key auto_increment,
Uname varchar (8) not null,
Sex char (2) default 'male'
);
Show tables from test; // view all tables
Desc user/show columns from user; // both can view the table structure
1. add columns (alter table + table name + add column name column type column parameter ):
For example, alter table user add birth date not null default '2017-00-00 ';
By default, columns are inserted at the end of the table. If you want to specify the position of the inserted column, the first, after keyword is required.
Alter table user add age int not null default '0' first/after uid;
2. Modify columns (
① Alter table + table name + modify + column name + new column type + new column parameters (only modify types and parameters );
② Alter table + table name + change + old column name + new column type + new column parameters (modify column name, type, and parameters );
):
Example: ① alter table user modify age varchar (2) not null;
② Alter table user change age info text;
3. delete a column (alter table + table name + drop + column name ):
Example: alter table user drop info;
4. view the creation code (show create table + table Name ):
Example: show create table user;
Ii. oracle
Cmd command start/Close listener: lsnrctl start/stop
Run the cmd command to start or close the service: net start/stop oracleserviceorcl
To be served...