Structured Query Language (Basics 2 video)

in #hive-1693212 years ago

▶️ Watch on 3Speak


As promised I'm back with another SQL tutorial, this one throws in some more basic concepts.
The code I used is below:

/*/////////////////////////////////////////////////////////////////////////

                    BASICS 2

NOT NULL = Ensures that a column cannot have a NULL value
UNIQUE = Ensures that all values in a column are different
PRIMARY KEY = A combination of a NOT NULL and UNIQUE
FOREIGN KEY = Prevents actions that would destroy links

///////////////////////////////////////////////////////////////////////////
*/

SELECT * FROM Persons;
CREATE TABLE Persons (
ID int NOT NULL PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int
);

INSERT INTO Persons(ID,LastName,FirstName,Age) VALUES(
001,
'Abdul Rahman',
'',
24
);

INSERT INTO Persons(ID,LastName,FirstName,Age) VALUES(
002,
'Abdul Kahar',
NULL,
24
);

CREATE TABLE Class(
ID INT FOREIGN KEY REFERENCES Persons(ID),
Present VARCHAR(3) NOT NULL,
Ddate VARCHAR(12) NOT NULL
);

INSERT INTO Class(ID,Present,Ddate) VALUES(
002,
'Yes',
'13/12/22'
);

SELECT * FROM Class

ALTER TABLE Class ADD signed VARCHAR(3)

ALTER TABLE friends ADD PRIMARY KEY (contact)


▶️ 3Speak

Sort:  

Are you also well-versed in pythonSQL?

I know my way around a few stuff

Yes I am

Awesome, I'd be checking out those content. I am bookmarking this cause I am currently learning SQL myself.

Wow

Let’s learn together then

Congratulations @gunu1! You received a personal badge!

Happy Hive Birthday! You are on the Hive blockchain for 1 year!

You can view your badges on your board and compare yourself to others in the Ranking

Check out our last posts:

HiveBuzz World Cup Contest - Semifinals - Recap of Day 1
The Hive Gamification Proposal Renewal
Support the HiveBuzz project. Vote for our proposal!

Congratulations @gunu1! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You published more than 20 posts.
Your next target is to reach 30 posts.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Check out the last post from @hivebuzz:

HiveBuzz World Cup Contest - Quarterfinals - Recap of Day 2
HiveBuzz World Cup Contest - Quarterfinals - Recap of Day 1
Support the HiveBuzz project. Vote for our proposal!