Using SQL Server through Command Prompt

Slides:



Advertisements
Similar presentations
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Advertisements

Oracle Data Dictionary. What Is Data Dictionary The oracle data dictionary is one of the most important components of the oracle DBMS It contains all.
Getting Started with Oracle11g Abeer bin humaid. Create database user You should create at least one database user that you will use to create database.
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
INTERNET APPLICATION DEVELOPMENT For More visit:
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Class #2: Introduction to MySQL (Continued) Where clause (continued) Aggregate Functions Creating users Backing up your database Indexes (if time) Importing.
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
 Mysql – popular open-source database management system  PHP usually works with Mysql for web- based database applications  LAMP applications—Web-based.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
DATABASE TOOLS CS 260 Database Systems. Overview  Database accounts  Oracle SQL Developer  MySQL Workbench.
4a. Structured Query Language - SELECT Statement Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
PHP and Mysql Database. PHP and Database Mysql – popular open-source database management system PHP usually works with Mysql for web-based database applications.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Understand Tables and How to Create Them Database Administration Fundamentals LESSON 2.2.
Oracle 11g: SQL Chapter 7 User Creation and Management.
13 Copyright © Oracle Corporation, All rights reserved. Controlling User Access.
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Introduction to Teradata Client Tools. 2 Introduction to Teradata SQL  OBJECTIVES :  Teradata Product Components.  Accessing Teradata – Database /
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
D Copyright © 2009, Oracle. All rights reserved. Using SQL*Plus.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9: Database Administration All Powder Board and Ski.
IS232 Lab 9. CREATE USER Purpose: Use the CREATE USER statement to create and configure a database user, which is an account through which you can log.
Rob Gleasure robgleasure.com
Web Systems & Technologies
Chapter 5 Introduction to SQL.
Rob Gleasure robgleasure.com
CS320 Web and Internet Programming SQL and MySQL
TABLES AND INDEXES Ashima Wadhwa.
SQL Implementation & Administration
Open Source Server Side Scripting Permissions & Users
SQL in Oracle.
CS1222 Using Relational Databases and SQL
ISC440: Web Programming 2 Server-side Scripting PHP 3
Client Access, Queries, Stored Procedures, JDBC
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Chapter 8 Working with Databases and MySQL
Session #, Speaker Name Indexing Chapter 8 11/19/2018.
CS1222 Using Relational Databases and SQL
Structured Query Language
Introduction To Structured Query Language (SQL)
HAVING,INDEX,COMMIT & ROLLBACK
Create New User in Database. First Connect the System.
CS1222 Using Relational Databases and SQL
Using SQL*Plus.
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
CS3220 Web and Internet Programming SQL and MySQL
Database Connections.
CS1222 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
Presentation transcript:

Using SQL Server through Command Prompt Lab 3 Database Engineering

Connecting to SQL Server Command: Sqlcmd –S Computername\instanceName.

Create New Login Create login user_name with password = ‘password'; Use GO statement to execute the query

Server level roles

Grant privileges To add server role: EXEC sp_addsrvrolemember ‘user_name', ‘server_role';

Create User for specific database USE database_name CREATE USER [User_name] FOR LOGIN [login_name]

Database Level Role

Grant privileges to the user EXEC sp_addrolemember, ‘database_role’ ‘user_name’

Creating database Command: Create database database_name

Opening specific database Command: Sqlcmd –S Computername\instanceName -d database- Name

Create table Command: create table table_name (column_name datatype, column_name datatype) Table with primary key

Supported data types in SQL server

Composite primary key 1> CREATE TABLE Customer ( 2> FirstName VARCHAR(15), 3> LastName VARCHAR (15), 4> CONSTRAINT pkey PRIMARY KEY (FirstName, LastName)

Index An index is a copy of selected columns of data from a table that can be searched very efficiently that also includes a low- level disk block address or direct link to the complete row of data it was copied from

Create index Create index index_name ON table_name (column-name)

Insert values into the table Insert into table_name values (value1, value2)

Select statement Select * from Table_Name

Using input file Sqlcmd –S Computername\instanceName – d database-name -i inputfile_path

Using input and output files Sqlcmd –S Computername\instanceName – d database-name -i input_filepath – o output_filepath

Directly run Query Note: using capital Q will run the query and exit SQLCMD

EXIT SQLCMD To end the sqlcmd session, type EXIT at the sqlcmd prompt.

Exercise Let's assume you are designing a flight reservation system. At its simplest, the application requires database tables for the flights, the customers, and the reservations. 1) Create the database and required tables using SQLCMD. Note: All tables should have primary key. Use composite primary key for customer table

Exercise 2) Create login for the server and give privileges of system administrator to it. 3) Create two users account for your database. Give the privileges of Database owner and read only to them. 4) Login with the user having privilege of database owner 5) Insert at least five records in each table 6) Create index for the flight and reservation table’s column .

Exercise 7) Show all tables data in command prompt 8) Write the select query for all created tables in script file and execute it through SQLCMD 9) Save the output of the select queries in output files using SQLCMD 10) Run direct query for selecting columns of tables in SQLCMD.