Creating and Altering Tables cis 407 Object Names Create Statement Alter statement Drop Statement.

Slides:



Advertisements
Similar presentations
Transaction Log file:.ldf Extent: 8 contiguous 8KB pages Page: 8KB Primary Data file:.mdf Secondary data file:.ndf Primary Data file:.mdf Secondary.
Advertisements

WaveMaker Visual AJAX Studio 4.0 Training
1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 9-1 COS 346 Day 21.
INTRODUCTION The Group WEB BROWSER FOR RELATION Goals.
Tools of the trade TSQL CIS 407. SQL Server Tools Books on line! Don’t use sql server authentication –Use windows authentication (safer) for developer.
Multiple Tiers in Action
Oracle SQL*plus John Ortiz. Lecture 10SQL: Overview2 Overview  SQL: Structured Query Language, pronounced S. Q. L. or sequel.  A standard language for.
Creating a Database Microsoft SQL Server. Create Database SQL Management Studio 1.In Object Explorer, connect to an instance of the SQL Server Database.
Chapter 10 Overview  Implement Microsoft Windows Authentication Mode and Mixed Mode  Assign login accounts to database user accounts and roles  Assign.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Session 7 Creating and Managing Databases. RDBMS and Data Management/ Session 7/2 of 27 Session Objectives Describe the system and user-defined databases.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Administration of Users Dr. Gabriel. 2 Documentation of User Administration Part of the administration process Reasons to document: –Provide a paper trail.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
1 Chapter Overview Creating a User Database Setting Database Options Managing User Database Size Placing Database Files on Multiple Disks.
Module 3: Changes to Transact-SQL. Overview Accessing Object Information New Transact-SQL Syntax Changes to Objects Distributed Queries.
Chapter 4 SQL. SQL server Microsoft SQL Server is a client/server database management system. Microsoft SQL Server is a client/server database management.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Company LOGO 1 Database Creation and Maintenance Jorge G. Martinez.
Module 9 Authenticating and Authorizing Users. Module Overview Authenticating Connections to SQL Server Authorizing Logins to Access Databases Authorization.
MISSION CRITICAL COMPUTING Moving Data and Other Planning Considerations.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
Database Unit Test MSSQL 2008 & VS 2010 Aung Kyaw Myo.
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
Module 10 Assigning Server and Database Roles. Module Overview Working with Server Roles Working with Fixed Database Roles Creating User-defined Database.
Module 5: Upgrading to SQL Server 7.0. Overview Planning an Upgrade Preparing to Upgrade Verifying the Upgrade Setting a Compatibility Level.
SELECT e.NationalIDNumber, p.FirstName,p.LastName, City FROM HumanResources.Employee e INNER JOIN Person.Person p on p.BusinessEntityID = e.BusinessEntityID.
Chapter 5 MYSQL Database. Introduction to MYSQL MySQL is the world's most popular open-source database. Open source means that the source code, the programming.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Roles & privileges privilege A user privilege is a right to execute a particular type of SQL statement, or a right to access another user's object. The.
Commercial RDBMSs Access and Oracle. Access DBMS Architchecture  Can be used as a standalone system on a single PC: -JET Engine -Microsoft Data Engine.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
SQL introduction 2013.
Visual Programing SQL Overview Section 1.
Permissions Lesson 13. Skills Matrix Security Modes Maintaining data integrity involves creating users, controlling their access and limiting their ability.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Module 11 Authorizing Users to Access Resources. Module Overview Authorizing User Access to Objects Authorizing Users to Execute Code Configuring Permissions.
Module 6: Data Protection. Overview What does Data Protection include? Protecting data from unauthorized users and authorized users who are trying to.
 Empowers to your customer  Product Rating and its Management in Ecommerce Framework  Product Reviews and Management: Collecting customer opinion about.
SQL Server 2005 Implementation and Maintenance Chapter 6: Security and SQL Server 2005.
Oracle 11g: SQL Chapter 7 User Creation and Management.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
SQL Server 2012 Session: 1 Session: 6 Creating and Managing Databases Data Management Using Microsoft SQL Server.
CREATE DATABASE database_name [ON [PRIMARY] [( [ NAME = logical_file_name,] [ FILENAME = ‘ os_file_name’] [, SIZE = size] [, MAXSIZE = {max_size|UNLIMITED}]
Introduction to SQL Server  Working with MS SQL Server and SQL Server Management Studio.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Advanced SQL - DDL Advanced Database Dr. AlaaEddin Almabhouh.
In this session, you will learn to: Manage databases Manage tables Objectives.
Auditing In SQL Server SQL Saturday #506 – Baltimore, BI Edition Presented By Brad McKuhen.
SQL Replication for RCSQL Reporting
Web Systems & Technologies
CS 3630 Database Design and Implementation
CS320 Web and Internet Programming SQL and MySQL
Using SQL Server through Command Prompt
Designing Database Solutions for SQL Server
Introduction to NetDB2 IST210.
Intermediate Security Topics in SQL SERver
Statistics for beginners – In-Memory OLTP
دستور Select SELECT [ALL|DISTINCT] [TOP () [FROM ] [WHERE ] [GROUP BY
Paul Jacobs The iSchool University of Maryland Thursday, Oct. 5, 2017
CS3220 Web and Internet Programming SQL and MySQL
CS3220 Web and Internet Programming SQL and MySQL
CS4540 Special Topics in Web Development SQL and MS SQL
Presentation transcript:

Creating and Altering Tables cis 407 Object Names Create Statement Alter statement Drop Statement

GUI v ANSI/TSQL ANSI works with all DBMSs – (e.g., oracle, db2, …) Need a script to insure same DB schema on development, test, production systems Easier (in my opinion)

Object Names in SQL Server [serverName.[DatabaseName.[SchemaName.]]]ObjectN ame Schema Name --- ownership Generally DBO – best to keep all relations in database owned by default DBO role. If my login is given create table authority then that table owned by beard.mytable If fred is db owner (created the database) a table he creates would be owned by fred.mytable Confusing Expensive: if relations in db owned by multiple owners than constantly must check access. –Stick to DBO by having anyone that needs to create tables have db sysadmin role.

Database, server names Select * from northwind.dbo.orders select * from northwind..orders (dbo default) Can access relation on another server Select * from myserver.northwind..orders –Server could be in PRC

Create Database CREATE DATABASE [on primary] ( [name =,] [,SIZE= ] [,MAXSIZE= ] [,filegrowth= ] ) ] [log on [name = ] ] ….. [collate ] ……

CREATE DATABASE Create database Accounting on (name = ‘accounting’, filename = ‘c:\program files\microsoft sql server\MSQL.1\mssql\data\accountingdata.mdf’., size = 10, maxsize = 50, fielgrowth = 5) Log on (name = ‘accountingLog’, filename = ‘c:\program files\microsoft SQL server\ sqsql.1\mssql\data\accountingLog.ldf’, size = 5MB, maxsize = 25MB, filegrowth=5mb) go

Create Table (pg 128) Create table customers ( customerNo intidentity(1,1) not null, customerName varchar(30) not null, address1 varchar(30) not null, address2 varchar(30) not null, ….. See example from web page Exec sp_help customers Tsql data types pg 12-15

Alter Statement Almost identical to create statement but change ‘create’ to ‘alter Don’t want to have to delete relation and recreate (lose all that data!!)

Drop statement Drop customers BE CAREFUL – no “are you sure” questions – it assumes you know what you are doing. Use master drop database accounting