SQL Commands List-Database Servers



SQL Commands
Command
Description
ALTER DATABASE
Alters the selected database by adding or removing files.
ALTER TABLE
Alters a table within a database by altering, adding, or dropping columns.
ALTER VIEW
Alters a previously created view.
CREATE DATABASE
Creates a new database.
CREATE PROCEDURE
Creates a stored procedure.
CREATE SCHEMA
Creates a schema within a database.
CREATE TABLE
Creates a table within a database.
CREATE VIEW
Creates a database view to a table(s).
DELETE
Deletes rows from a table.
DROP DATABASE
Removes a database by deleting its files.
DROP PROCEDURE
Removes a stored procedure.
DROP TABLE
Removes a table from a database.
DROP VIEW
Removes a view from a database.
INSERT
Adds a new row to a table or view.
SELECT
Selects fields within a given table(s) for viewing.
USE
Uses a particular database for the commands following.
The best countermeasure for controlling stored procedures is simply to delete them. You can do so by taking these steps:
1.       Use the Microsoft SQL Server Enterprise Manager to open the database desired, usually Master.
2.       Expand the Extended Stored Procedures folder within the database.
3.       Right click on the stored procedure.
4.       For SQL Servers 7.x, 8.x, and 2000 select the Delete feature to remove the stored procedure.
If removing the stored procedures outright isn't an option before extensive testing is performed, you can restrict the permissions on the stored procedures. To perform ACLing on the SPs, follow this procedure:
1.       Use the Microsoft SQL Server Enterprise Manager to open the database desired, usually Master.
2.       Expand the Extended Stored Procedures folder within the database.
3.       Right click on the stored procedure.
4.       Select Properties.
5.       Click on the Permissions tab.
6.       Change the permissions as desired.

Part of the Transact-SQL reference, Microsoft SQL 2000 provides a litany of simple functions that can be called directly within an SQL string to provide valuable information. Here is a short list of helpful functions:
db_id()
Displays the database ID. Example: select db_id(); or use mydb; select db_id()
db_name()
Displays the currently used database name and is helpful in understanding what database is being used by default. Example: select db_name();
file_name(<ID>)
Displays the logical file name for the supplied file identifier (ID) and is helpful for enumerating all the files within a database. Example: select file_name(1) or use mydb; select file_name(1);
Getdate()
Displays the date and time on the system. select getdate()
object_name(<parm>)
Displays the database object name and is helpful in enumerating the various objects within a database. select object_name(1) or use mydb; select object_name(1)
setuser <user>
Impersonates a user but is valid only if existing user is member of sysadmin or db_owner fixed database role. setuser 'jane';
current_user
Displays the currently logged in user for the SQL session and is helpful in identifying the user making database queries. select current_user;
These Transact-SQL functions can be enormously helpful to an attacker.

An attacker would salivate over this information. Other keywords that can be used are:
CHECK_CONSTRAINTS
COLUMN_DOMAIN_USAGE
COLUMN_PRIVILEGES
COLUMNS
CONSTRAINT_COLUMN_USAGE
CONSTRAINT_TABLE_USAGE
DOMAIN_CONSTRAINTS
DOMAINS
KEY_COLUMN_USAGE
PARAMETERS
REFERENTIAL_CONSTRAINTS
ROUTINES
ROUTINE_COLUMNS
SCHEMATA
TABLE_CONSTRAINTS
TABLE_PRIVILEGES
TABLES
VIEW_COLUMN_USAGE
VIEW_TABLE_USAGE
VIEWS
Unfortunately, this functionality, also, is inherent in Microsoft SQL Server and cannot be shut off.

Master.dbo Default System Stored and Extended Stored Procedures
Procedure
Description
sp_addmessage
Adds a new error message to the sysmessages table.
sp_configure
Displays or changes global configuration settings such as c2 audit mode, allow updates, remote access, remote login timeout, user connections, and the like.
sp_help
Can enumerate just about anything on the SQL Server itself, including all objects.
sp_helpdb
Lists the databases available and, when used with a database name as a parameter, displays specific database information.
sp_helpprotect
Displays information on permissions for objects.
sp_OACreate
Creates an instance of the OLE object.
sp_OADestroy
Destroys an OLE object.
sp_OAGetErrorInfo
Displays OLE Automation error information.
sp_OAGetProperty
Displays a property value of an OLE object.
sp_OAMethod
Calls a method of an OLE object.
sp_OASetProperty
Sets a property of an OLE object.
sp_OAStop
Stops the OLE Automation stored procedure.
sp_password
Adds or changes a password for an SQL Server login. Examples: EXEC sp_password 'oldpass', 'newpass', 'sa'.
sp_tables
Displays the tables for the current database. Helpful in enumerating all the tables within a database. Examples: EXEC sp_tables or use mydb; EXEC sp_tables;.
sp_who
Displays information on SQL Server connections such as status, login name, host name where the connection is coming from, and database name and commands such as SELECT.
xp_availablemedia
Reveals the available drives on the machine.
xp_cmdshell
Runs arbitrary commands with administrator privilege.
xp_deletemail
Deletes a message from the Microsoft SQL Server inbox.
xp_dirtree
Allows a directory tree to be obtained.
xp_dsninfo
Displays the ODBC DSN information.
xp_enumdsn
Enumerates ODBC data sources on the server.
xp_enumgroups
Displays a list of Windows groups on the system. Example: EXEC master..xp_dirtree.
xp_eventlog
Displays event logs from the Windows system.
xp_fixeddrives
Displays the fixed drives on the system and its free space in MB.
xp_getfiledetails
Displays the properties of a given file. Example: EXEC master..xp_getfiledetails 'c:\winnt.ini'.
xp_getnetname
Displays the running system's NetBIOS name.
xp_grantlogin
Grants login rights of the specified user. Example: EXEC master..xp_grantlogin administrator.
xp_logevent
Logs a user-defined message in the SQL Server log file.
xp_loginconfig
Reveals information about the security mode of the server.
xp_logininfo
Displays the login information of the various users.
xp_makecab
Allows the user to create a compressed archive of files on the server (or any files the server can access).
xp_msver
Displays the Microsoft SQL Server version, including all information about the operating system. Example: EXEC master..xp_msver.
xp_ntsec_enumdomains
Enumerates domains that the server can access.
xp_readerrorlog
Displays the SQL Server error log.
xp_readmail
Reads a mail message in the SQL Server inbox.
xp_regaddmultistring
Adds a multi string registry key.
xp_regdeletekey
Deletes a registry key.
xp_regdeletevalue
Deletes a value within a registry key.
xp_regenumkeys
Enumerates registry key.
xp_regenumvalues
Enumerates registry key values.
xp_regread
Reads a registry key.
xp_regremovemultistring
Removes a multistrong registry key.
xp_regwrite
Writes to a registry key.
xp_revokelogin
Revokes access from a Windows group or user.
xp_sendmail
Sends a message to someone.
xp_servicecontrol
Allows a user to start or stop a Windows service. Examples: EXEC master..xp_servicecontrol 'start', 'schedule'.
xp_startmail
Starts an SQL Server mail client session.
xp_stopmail
Stops an SQL Server mail client session.
xp_subdirs
Displays a list of subdirectories.
xp_terminate_process
Terminates a process, given its process ID (PID).
xp_unc_to_drive
Unknown.



Related Posts:
  • LG L80-the magic LG L90, L70 and L40. They will soon be joined by a fourth member, L80 and today we get to optically discern how the upcoming mid-range looks akin to. We got images of the dual SIM version of the L80, which comes … Read More
  • Nokia Lumia Lumia 930 launch date, but Microsoft and Nokia may have moved up the schedule.  The Nokia Lumia 630 will succeed the 620, which got lost in the shadow of the highly popular Lumia 520. Its rumored specifications inc… Read More
  • Amazon's smartphone The images reveal the yet to be announced handset wearing typical for prototype devices, hard enclosure which hides its design. The leaked images show a whopping five front-facing camera units on the device. One of … Read More
  • Oppo N1 Oppo N1 Oppo N1, the company's last year flagship smartphone is now available for a discounted price tag in Europe. The smartphone can now be picked from the Oppo Style webstore for €369 (about $500). Oppo N1 on a mun… Read More
  • LG Lucid 3-come the new LG Lucid 3 for Verizon is a pretty decent handset, and it can be yours for $300, no strings attached. If you don't mind signing on the dotted line for a two year agreement,  then you could always get the devic… Read More
  • The Motorola Moto X The Motorola Moto X- speedy camera                Nice voice command well-crafted design.          &n… Read More
  • Sprint Android 4.4.3 for the Nexus 5 Android 4.4.3 KitKat update is out today for and the Nexus 5 users on Sprint are the first to get it. Carrying a version number KTU48F the update enables  the device to work on Sprint's LTE network on bands 26 and 4… Read More
  • Microsoft to release two GDR updates for WP8.1 Microsoft separates Windows Phone 8 updates into major and minor ones -   so far we've seen one major 8.1 and three minor ones GDR 1, 2 and 3. The company is reportedly planning at least two GDR updates for … Read More
  • how to make money online  http://money-clips-online.com  http://www.turboonlinebusiness.com  http://www.affiliatejob.org  http://www.onlinemoneymakingsecrets.biz  http://onlineworknet.com  http://reeonlinemoney.n… Read More
  • Samsung Galaxy S5 costs Analytics company IHS has released its teardown report of the Samsung Galaxy S5,  which also reveals an estimate of the phone's bill of materials how much its parts cost.  The Galaxy S5 costs Samsung about … Read More
  • Nokia Oyj The Microsoft acquisition of Nokia Contrivances and Accommodations is expected to close later  this month and to prepare for the transition a letter has been sent out to Nokia's supplier base. The letter, which has l… Read More
  • Nokia Lumia 630 - Russia- just €160 Nokia Lumia 630 went official just a few days ago. It is among the first smartphones to run Windows Phone 8.1 with Lumia Cyan out of the box.  The smartphone is considered as a successor of the Lumia 620. Nokia has … Read More
  • ways to make money at home fast How to turn a little money into - learn to trade stock options find a job use the beehives  new job search engine to find work just enter a few keywords, and your location, and you re on your way it s easy and free. Wi… Read More
  • LG G3 screenies-come The overall look and feel of the latest Optimus UI on top of Android 4.4 KitKat  is very clean and flat, a trend that a lot of manufacturers are embracing. Everything from the icons, launcher and notification drawe… Read More
  • Japanese market-LG G3 The Japanese market version of LG's yet to be revealed G3 flagship might have leaked  on Twitter. A duo of press shots showing a mysterious high-end LG handset made the rounds on the social network, courtesy of @evl… Read More