Basic commands for manipulating sqlserver/oracle databases under CMD

Source: Internet
Author: User
Tags windows manual import database sqlplus

Basic command for manipulating SQL Server databases under cmd:
1.
(1) First enter the command SQL command line, log into the database
Log on to the local database system
Sqlcmd-u [Username]-p [Password]
(3) Querying all database names
Select name from sysdatabases
(4) Manipulating the database
Use [DataBaseName]
Go
(5) Show all table names under this database
Select name from sysobjects where type= ' U '
Go
(6) Display all fields of the data table
Select Name from syscolumns Where id=object_id (' TableName ')
Go
(7) Querying data table fields and data types
Select Column_name,data_type from information_schema.columns where table_name = N ' TableName '
Go
(8) Querying table-related views, stored procedures, functions
Select a.* from sysobjects A, syscomments b where a.id = b.ID and b.text like '%tablename% '
Go
(9) Backup database to disk specified location (full backup)
Backup database [DatabaseName] to disk= ' F:\[databasenewname].back '
Go

(10) Connect to a database under a specific server

sqlcmd-s [Server name]-d [Database]-u [username]-p [Password]

CMD under Operation Oracle:

(1) Modify user password
1, Sqlplus/nolog

2, Conn/as SYSDBA

3, ALTER user [user name] identified by [password];

(2) Import Database operations

1. Create User: Wsbahn
2. Authorization
Cmd:sqlplus/as SYSDBA
Grant Connect,session,resource to Wsbahn;
3. Use Wsbahn to create a database connection
Cmd:imp [username]/[passwd] file=e:\*.dmp buffer=50000 full=y

4. Exit

(3) Troubleshooting Windows manual execution script cleanup Oracle process consuming memory issues

The script is as follows:

@echo off
Title Oracle Service Management
Cls
Color 2f
Goto MENU
: MENU
Cls
Echo. =-=-=-=-=oracle Service Management =-=-=-=-=
Echo.
Echo. 1 Open Service
Echo.
Echo. 2 Closing the service
Echo.
Echo. 3 exit
Echo.
Echo. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Echo. Please enter the serial number of the selected item:
set/p id=
If "%id%" = = "1" goto CMD1
If "%id%" = = "2" goto CMD2
If "%id%" = = "3" exit
echo Please enter the correct serial number! &ping-n 2 127.1>nul&goto MENU
: cmd1
Echo.
Echo opens the Oracle service ...
NET start|findstr/i/C: "ORACLEDBCONSOLEORCL" >nul&&set k=1| | Set k=0
If%k%==0 (net start "ORACLEDBCONSOLEORCL")
NET start|findstr/i/C: "Oracleoradb10g_home1isql*plus" >nul&&set k=1| | Set k=0
If%k%==0 (net start "Oracleoradb10g_home1isql*plus")
NET start|findstr/i/C: "Oracleoradb10g_home1tnslistener" >nul&&set k=1| | Set k=0
If%k%==0 (net start "Oracleoradb10g_home1tnslistener")
NET start|findstr/i/C: "ORACLESERVICEORCL" >nul&&set k=1| | Set k=0
If%k%==0 (net start "ORACLESERVICEORCL")
Echo.
echo Oracle Service has been successfully opened ...
Echo.
Pause
Exit
: CMD2
Echo.
Echo Close the Oracle service ...
NET start|findstr/i/C: "ORACLEDBCONSOLEORCL" >nul&&set k=1| | Set k=0
If%k%==1 (net stop "ORACLEDBCONSOLEORCL")
NET start|findstr/i/C: "Oracleoradb10g_home1isql*plus" >nul&&set k=1| | Set k=0
If%k%==1 (net stop "Oracleoradb10g_home1isql*plus")
NET start|findstr/i/C: "Oracleoradb10g_home1tnslistener" >nul&&set k=1| | Set k=0
If%k%==1 (net stop "Oracleoradb10g_home1tnslistener")
NET start|findstr/i/C: "ORACLESERVICEORCL" >nul&&set k=1| | Set k=0
If%k%==1 (net stop "ORACLESERVICEORCL")
Echo.
Echo Oracle Service has successfully shut down ...
Echo.
Pause
Exit

Basic commands for manipulating sqlserver/oracle databases under CMD

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.