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