Mysql: some basic oracle database operations _ MySQL

Source: Internet
Author: User
This is the command and statement that you collect online and use at ordinary times (suitable for beginners to learn). if there are any errors, please point out mysql (note that there is an empty 26684 between commands ;) run the cmd command to start and close the database: netstartstopmysql to open mysql and enter mysql. this is the command and statement that you collect on the Internet and use on your own (suitable for beginners). if there is any problem, please point it out.

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...

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.