@king_sebastine

sql2

# ✅ **1. Create a table `Product` with id, price, and another column** “`sqlCREATE TABLE Product ( ProductId INT IDENTITY(1,1) PRIMARY KEY, Price DECIMAL(10,2) NOT NULL, ProductName VARCHAR(100) NOT NULL);“` — # ✅ **2. Add a constraint to that table** ### Example: add a constraint that **Price must be greater than 0** “`sqlALTER TABLE ProductADD […]

sql2 Read More »

SQL

USE master;GOALTER DATABASE examdb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;GODROP DATABASE IF EXISTS examdb;CREATE DATABASE examdb;USE examdb; create table students (stdid INT,FullName NVARCHAR(100),Email NVARCHAR(100),GPA DECIMAL (10,2),age DECIMAL (10),constraint pk_students_stdid primary key(stdid)); CREATE NONCLUSTERED INDEX IX_STUDENTS_EMAILON students (Email); CREATE NONCLUSTERED INDEX IX_STUDENTS_ageON students (age); /select name from sys.key_constraints where parent_object_id= object_id(‘students’); alter table students drop constraint PK_students_stdid;/

SQL Read More »