Mysql and oracle Database basic operations, mysqloracle

Source: Internet
Author: User

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


Related Article

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.