
Ch 6: Working With Tables and Other SQL Need-To-Knows
Creating SQL tables When creating tables, you need to define the columns and their data types. CREATE TABLE table_name ( column1 datatype , column2 datatype , column3 datatype , ) We are going to call our table customer_data, and it will have the columns customer_id, customer_name, and dob. CREATE TABLE customer_data ( customer_id INT PRIMARY KEY , customer_name VARCHAR ( 50 ), dob datatype DATETIME ); Inserting data into the table This is the syntax for inserting multiple rows into a table: INSERT INTO table_name ( column1 , column2 , column3 ) VALUES ( value1 , value2 , value3 ), ( value1 , value2 , value3 ); For our customer data: INSERT INTO table_name ( customer_id , customer_name , dob ) VALUES ( 1 , 'Jacky' , '25-06-1980' ), ( 2 , 'Mike' , '02-10-2003' ); Viewing data in a table You use the command SELECT to view data in a table. To see all data, you use an asterisk* 'SELECT * FROM table_name` If you want to view data from a specific column, you replace the asterisk with the col
Continue reading on Dev.to Tutorial
Opens in a new tab




