SQL My Notes

(under construction)

Topic Notes
Database (Create & Drop) This is normally done via a Control Center or some Database Management tool provide by the DB vendor.

SQL Example:

  • create database SAMPLE;
  • drop database SAMPLE;
Connect to a Database SQL Example
  • connect to SAMPLE;
  • connect to SAMPLE user USERNAME; - allows user & password access.
Create a Table SQL Example (DB2)
  • Warning: Be careful with the field type: DATE.  Some DB's don't support it.
  • create table TEST ( "USERID" character (8)  not null, "FIRST" character (15), "LAST" character(20), primary key (USERID) );
  • create table Sample (charTest char(10), charYYYYMMDD char(8), intTest integer, numTest numeric(6,2), smintTest smallint, varTest varchar(1023) )
Drop a Table SQL Example
  • drop table TEST;
Insert a row SQL Example
  • insert into TEST (USERID, FIRST, LAST) values ('THOMASMA','Michael', 'Thomas');
Delete a row SQL Example
  • delete from TEST where USERID like 'THOMASMA';
Select SQL Example
  • select * from TEST;
  • select * from TEST where ( USERID = 'THOMASMA')
Operators Operators
  • % - wildcard for any number of characters
  • ? - wildcard for one character.
  • like "%test%"  //like = having matching characters.
  • like "test%"
  • like "%test"
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

SQL - MS SQL Notes

Creating a Database create database SampleDb
  • I'm sure that there are plenty additional parameters.   In my environment .75 Mb was allocated to the database and .49MB to Michael_log.
Dropping a Database drop database Michael
GUI Tool
Query Analyzer
GUI Tool for SQL command access.
  • Query Analyzer - This is the client tool used to execute SQL commands.
  • Connecting to a Database - this is done by selecting the drop down list in the upper right corner.
Date Date (field type)
  • Looks like MS SQL does not support the field: DATE .  I'm not the authority, just my experience.
   
   
   
   
   
   

SQL - DB2 Notes

   
   
   
   
   
   
   
   
   
   

SQL - Oracle Notes

   
   
   
   
   
   
   
   
   
   

SQL - MySQL Notes