Tutorial by Examples

A basic Employees table, containing an ID, and the employee's first and last name along with their phone number can be created using CREATE TABLE Employees( Id int identity(1,1) primary key not null, FName varchar(20) not null, LName varchar(20) not null, PhoneNumber varchar(10)...
You may want to create a duplicate of a table: CREATE TABLE ClonedEmployees AS SELECT * FROM Employees; You can use any of the other features of a SELECT statement to modify the data before passing it to the new table. The columns of the new table are automatically created according to the selec...
To duplicate a table, simply do the following: CREATE TABLE newtable LIKE oldtable; INSERT newtable SELECT * FROM oldtable;
Below you could find the table Employees with a reference to the table Cities. CREATE TABLE Cities( CityID INT IDENTITY(1,1) NOT NULL, Name VARCHAR(20) NOT NULL, Zip VARCHAR(10) NOT NULL ); CREATE TABLE Employees( EmployeeID INT IDENTITY (1,1) NOT NULL, FirstName VARCHA...
PostgreSQL and SQLite To create a temporary table local to the session: CREATE TEMP TABLE MyTable(...); SQL Server To create a temporary table local to the session: CREATE TABLE #TempPhysical(...); To create a temporary table visible to everyone: CREATE TABLE ##TempPhysicalVisibleToEveryo...

Page 1 of 1